Skip to content

Commit cba4abb

Browse files
author
Marco Gorelli
committed
📝 add whatsnew entry to v1.0.1
1 parent 3e71284 commit cba4abb

File tree

3 files changed

+49
-18
lines changed

3 files changed

+49
-18
lines changed

doc/source/whatsnew/v1.0.0.rst

-1
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,6 @@ Reshaping
12471247
- Bug in :func:`merge_asof` merging on a tz-aware ``left_index`` and ``right_on`` a tz-aware column (:issue:`29864`)
12481248
- Improved error message and docstring in :func:`cut` and :func:`qcut` when `labels=True` (:issue:`13318`)
12491249
- Bug in missing `fill_na` parameter to :meth:`DataFrame.unstack` with list of levels (:issue:`30740`)
1250-
- :meth:`DataFrame.merge` now preserves right frame's row order when executing a right merge (:issue:`27453`)
12511250

12521251
Sparse
12531252
^^^^^^

doc/source/whatsnew/v1.0.1.rst

+32
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,38 @@ including other versions of pandas.
1010

1111
.. ---------------------------------------------------------------------------
1212
13+
.. _whatsnew_101.api_breaking:
14+
15+
Backwards incompatible API changes
16+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17+
18+
:meth:`DataFrame.merge` preserves right frame's row order
19+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
:meth:`DataFrame.merge` now preserves right frame's row order when executing a right merge (:issue:`27453`)
21+
22+
.. ipython:: python
23+
24+
left_df = pd.DataFrame({'animal': ['dog', 'pig'], 'max_speed': [40, 11]})
25+
right_df = pd.DataFrame({'animal': ['quetzal', 'pig'], 'max_speed': [80, 11]})
26+
left_df
27+
right_df
28+
29+
*pandas 1.0.0*
30+
31+
.. code-block:: python
32+
33+
>>> left_df.merge(right_df, on=['animal', 'max_speed'], how="right")
34+
animal max_speed
35+
0 pig 11
36+
1 quetzal 80
37+
38+
*pandas 1.0.1*
39+
40+
.. ipython:: python
41+
42+
left_df.merge(right_df, on=['animal', 'max_speed'], how="right")
43+
44+
.. ---------------------------------------------------------------------------
1345
1446
.. _whatsnew_101.bug_fixes:
1547

pandas/tests/reshape/merge/test_merge.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -2174,25 +2174,25 @@ def test_merge_datetime_upcast_dtype():
21742174
@pytest.mark.parametrize("how", ["left", "right"])
21752175
def test_merge_preserves_row_order(how):
21762176
# GH 27453
2177-
population = [
2178-
("Jenn", "Jamaica", 3),
2179-
("Beth", "Bulgaria", 7),
2180-
("Carl", "Canada", 30),
2181-
]
2182-
columns = ["name", "country", "population"]
2183-
population_df = DataFrame(population, columns=columns)
2177+
population_df = DataFrame(
2178+
{
2179+
"name": ["Jenn", "Beth", "Carl"],
2180+
"country": ["Jamaica", "Bulgaria", "Canada"],
2181+
"population": [3, 7, 30],
2182+
}
2183+
)
21842184

2185-
people = [("Abe", "America"), ("Beth", "Bulgaria"), ("Carl", "Canada")]
2186-
columns = ["name", "country"]
2187-
people_df = DataFrame(people, columns=columns)
2185+
people_df = DataFrame(
2186+
{"name": ["Abe", "Beth", "Carl"], "country": ["America", "Bulgaria", "Canada"]}
2187+
)
21882188

2189-
expected_data = [
2190-
("Abe", "America", np.nan),
2191-
("Beth", "Bulgaria", 7),
2192-
("Carl", "Canada", 30),
2193-
]
2194-
expected_cols = ["name", "country", "population"]
2195-
expected = DataFrame(expected_data, columns=expected_cols)
2189+
expected = DataFrame(
2190+
{
2191+
"name": ["Abe", "Beth", "Carl"],
2192+
"country": ["America", "Bulgaria", "Canada"],
2193+
"population": [np.nan, 7, 30],
2194+
}
2195+
)
21962196

21972197
if how == "right":
21982198
left_df, right_df = population_df, people_df

0 commit comments

Comments
 (0)