Skip to content

Commit

Permalink
📝 add whatsnew entry to v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Gorelli committed Jan 30, 2020
1 parent 3e71284 commit cba4abb
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 18 deletions.
1 change: 0 additions & 1 deletion doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,6 @@ Reshaping
- Bug in :func:`merge_asof` merging on a tz-aware ``left_index`` and ``right_on`` a tz-aware column (:issue:`29864`)
- 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`)

Sparse
^^^^^^
Expand Down
32 changes: 32 additions & 0 deletions doc/source/whatsnew/v1.0.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,38 @@ including other versions of pandas.

.. ---------------------------------------------------------------------------
.. _whatsnew_101.api_breaking:

Backwards incompatible API changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

: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`)

.. ipython:: python
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 1.0.0*

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

.. ipython:: python
left_df.merge(right_df, on=['animal', 'max_speed'], how="right")
.. ---------------------------------------------------------------------------
.. _whatsnew_101.bug_fixes:

Expand Down
34 changes: 17 additions & 17 deletions pandas/tests/reshape/merge/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2174,25 +2174,25 @@ def test_merge_datetime_upcast_dtype():
@pytest.mark.parametrize("how", ["left", "right"])
def test_merge_preserves_row_order(how):
# GH 27453
population = [
("Jenn", "Jamaica", 3),
("Beth", "Bulgaria", 7),
("Carl", "Canada", 30),
]
columns = ["name", "country", "population"]
population_df = DataFrame(population, columns=columns)
population_df = DataFrame(
{
"name": ["Jenn", "Beth", "Carl"],
"country": ["Jamaica", "Bulgaria", "Canada"],
"population": [3, 7, 30],
}
)

people = [("Abe", "America"), ("Beth", "Bulgaria"), ("Carl", "Canada")]
columns = ["name", "country"]
people_df = DataFrame(people, columns=columns)
people_df = DataFrame(
{"name": ["Abe", "Beth", "Carl"], "country": ["America", "Bulgaria", "Canada"]}
)

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

if how == "right":
left_df, right_df = population_df, people_df
Expand Down

0 comments on commit cba4abb

Please sign in to comment.