Skip to content

Commit

Permalink
🔀 fix conflicts, fix nameerror in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Gorelli committed Jan 24, 2020
1 parent 6737d3a commit 4cf9afe
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 50 deletions.
34 changes: 16 additions & 18 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -300,38 +300,40 @@ New repr for :class:`~pandas.arrays.IntervalArray`
pd.arrays.IntervalArray.from_tuples([(0, 1), (2, 3)])
``DataFrame.rename`` now only accepts one positional argument
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- :meth:`DataFrame.rename` would previously accept positional arguments that would lead
to ambiguous or undefined behavior. From pandas 1.0, only the very first argument, which
maps labels to their new names along the default axis, is allowed to be passed by position
(:issue:`29136`).
- :meth:`DataFrame.merge` now preserves right frame's row order when executing a right merge (:issue:`27453`)
:meth:`DataFrame.merge` preserves right frame's row order
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:meth:`DataFrame.merge` now preserves right frame's row order when executing a right merge (:issue:`27453`)

.. code-block:: python
.. ipython:: python
left_df = pd.DataFrame({"colors": ["blue", "red"]}, index=pd.Index([0, 1]))
right_df = pd.DataFrame({"hats": ["small", "big"]}, index=pd.Index([1, 0]))
left_df = pd.DataFrame({'animal': ['dog', 'pig'], 'max_speed': [40, 11]})
right_df = pd.DataFrame({'animal': ['quetzal', 'pig'], 'max_speed': [80, 11]})
left_df
right_df
*pandas 0.25.x*

.. code-block:: python
left_df.merge(right_df, left_index=True, right_index=True, how="right")
>>> left_df.merge(right_df, on=['animal', 'max_speed'], how="right")
animal max_speed
0 pig 11
1 quetzal 80
*pandas 1.0.0*

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

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

*pandas 0.25.x*

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

Sparse
^^^^^^
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/reshape/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,10 @@ def __init__(
indicator: bool = False,
validate=None,
):
left = validate_operand(left)
right = validate_operand(right)
self.left = self.orig_left = left
self.right = self.orig_right = right
_left = _validate_operand(left)
_right = _validate_operand(right)
self.left = self.orig_left = _left
self.right = self.orig_right = _right
self.how = how
self.axis = axis

Expand Down
28 changes: 0 additions & 28 deletions pandas/tests/reshape/merge/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2194,34 +2194,6 @@ def test_merge_preserves_row_order(how):
expected_cols = ["name", "country", "population"]
expected = DataFrame(expected_data, columns=expected_cols)

result = pop.merge(ppl, on=("name", "country"), how="right")

tm.assert_frame_equal(result, expected)


def test_left_merge_preserves_row_order():
# GH 27453
population = [
("Jenn", "Jamaica", 3),
("Beth", "Bulgaria", 7),
("Carl", "Canada", 30),
]
columns = ["name", "country", "population"]
pop = DataFrame(population, columns=columns)

people = [("Abe", "America"), ("Beth", "Bulgaria"), ("Carl", "Canada")]
columns = ["name", "country"]
ppl = DataFrame(people, columns=columns)

expected_data = [
("Abe", "America", np.nan),
("Beth", "Bulgaria", 7),
("Carl", "Canada", 30),
]
expected_cols = ["name", "country", "population"]
expected = DataFrame(expected_data, columns=expected_cols)

result = ppl.merge(pop, on=("name", "country"), how="left")
if how == "right":
left_df, right_df = population_df, people_df
elif how == "left":
Expand Down

0 comments on commit 4cf9afe

Please sign in to comment.