Skip to content

Commit 4cf9afe

Browse files
author
Marco Gorelli
committed
🔀 fix conflicts, fix nameerror in tests
1 parent 6737d3a commit 4cf9afe

File tree

3 files changed

+20
-50
lines changed

3 files changed

+20
-50
lines changed

doc/source/whatsnew/v1.0.0.rst

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -300,38 +300,40 @@ New repr for :class:`~pandas.arrays.IntervalArray`
300300
301301
pd.arrays.IntervalArray.from_tuples([(0, 1), (2, 3)])
302302
303-
``DataFrame.rename`` now only accepts one positional argument
304-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
305-
306-
- :meth:`DataFrame.rename` would previously accept positional arguments that would lead
307-
to ambiguous or undefined behavior. From pandas 1.0, only the very first argument, which
308-
maps labels to their new names along the default axis, is allowed to be passed by position
309-
(:issue:`29136`).
310-
- :meth:`DataFrame.merge` now preserves right frame's row order when executing a right merge (:issue:`27453`)
311303
:meth:`DataFrame.merge` preserves right frame's row order
312304
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
313305
:meth:`DataFrame.merge` now preserves right frame's row order when executing a right merge (:issue:`27453`)
314306

315-
.. code-block:: python
307+
.. ipython:: python
316308
317-
left_df = pd.DataFrame({"colors": ["blue", "red"]}, index=pd.Index([0, 1]))
318-
right_df = pd.DataFrame({"hats": ["small", "big"]}, index=pd.Index([1, 0]))
309+
left_df = pd.DataFrame({'animal': ['dog', 'pig'], 'max_speed': [40, 11]})
310+
right_df = pd.DataFrame({'animal': ['quetzal', 'pig'], 'max_speed': [80, 11]})
319311
left_df
320312
right_df
321313
322314
*pandas 0.25.x*
323315

324316
.. code-block:: python
325-
left_df.merge(right_df, left_index=True, right_index=True, how="right")
317+
318+
>>> left_df.merge(right_df, on=['animal', 'max_speed'], how="right")
319+
animal max_speed
320+
0 pig 11
321+
1 quetzal 80
326322
327323
328324
*pandas 1.0.0*
329325

330-
.. code-block:: python
331-
left_df.merge(right_df, left_index=True, right_index=True, how="right")
326+
.. ipython:: python
332327
328+
left_df.merge(right_df, on=['animal', 'max_speed'], how="right")
333329
330+
``DataFrame.rename`` now only accepts one positional argument
331+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
334332

333+
- :meth:`DataFrame.rename` would previously accept positional arguments that would lead
334+
to ambiguous or undefined behavior. From pandas 1.0, only the very first argument, which
335+
maps labels to their new names along the default axis, is allowed to be passed by position
336+
(:issue:`29136`).
335337

336338
*pandas 0.25.x*
337339

@@ -1179,13 +1181,9 @@ Reshaping
11791181
- Bug in :func:`melt` where supplying mixed strings and numeric values for ``id_vars`` or ``value_vars`` would incorrectly raise a ``ValueError`` (:issue:`29718`)
11801182
- Dtypes are now preserved when transposing a ``DataFrame`` where each column is the same extension dtype (:issue:`30091`)
11811183
- Bug in :func:`merge_asof` merging on a tz-aware ``left_index`` and ``right_on`` a tz-aware column (:issue:`29864`)
1182-
<<<<<<< HEAD
11831184
- Improved error message and docstring in :func:`cut` and :func:`qcut` when `labels=True` (:issue:`13318`)
11841185
- Bug in missing `fill_na` parameter to :meth:`DataFrame.unstack` with list of levels (:issue:`30740`)
11851186
- :meth:`DataFrame.merge` now preserves right frame's row order when executing a right merge (:issue:`27453`)
1186-
=======
1187-
>>>>>>> 2b1b67592... changes requested by jreback
1188-
-
11891187

11901188
Sparse
11911189
^^^^^^

pandas/core/reshape/merge.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,10 @@ def __init__(
568568
indicator: bool = False,
569569
validate=None,
570570
):
571-
left = validate_operand(left)
572-
right = validate_operand(right)
573-
self.left = self.orig_left = left
574-
self.right = self.orig_right = right
571+
_left = _validate_operand(left)
572+
_right = _validate_operand(right)
573+
self.left = self.orig_left = _left
574+
self.right = self.orig_right = _right
575575
self.how = how
576576
self.axis = axis
577577

pandas/tests/reshape/merge/test_merge.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,34 +2194,6 @@ def test_merge_preserves_row_order(how):
21942194
expected_cols = ["name", "country", "population"]
21952195
expected = DataFrame(expected_data, columns=expected_cols)
21962196

2197-
result = pop.merge(ppl, on=("name", "country"), how="right")
2198-
2199-
tm.assert_frame_equal(result, expected)
2200-
2201-
2202-
def test_left_merge_preserves_row_order():
2203-
# GH 27453
2204-
population = [
2205-
("Jenn", "Jamaica", 3),
2206-
("Beth", "Bulgaria", 7),
2207-
("Carl", "Canada", 30),
2208-
]
2209-
columns = ["name", "country", "population"]
2210-
pop = DataFrame(population, columns=columns)
2211-
2212-
people = [("Abe", "America"), ("Beth", "Bulgaria"), ("Carl", "Canada")]
2213-
columns = ["name", "country"]
2214-
ppl = DataFrame(people, columns=columns)
2215-
2216-
expected_data = [
2217-
("Abe", "America", np.nan),
2218-
("Beth", "Bulgaria", 7),
2219-
("Carl", "Canada", 30),
2220-
]
2221-
expected_cols = ["name", "country", "population"]
2222-
expected = DataFrame(expected_data, columns=expected_cols)
2223-
2224-
result = ppl.merge(pop, on=("name", "country"), how="left")
22252197
if how == "right":
22262198
left_df, right_df = population_df, people_df
22272199
elif how == "left":

0 commit comments

Comments
 (0)