Skip to content

Commit cb2d4d1

Browse files
committed
2nd change after review
1 parent 9310361 commit cb2d4d1

File tree

3 files changed

+15
-22
lines changed

3 files changed

+15
-22
lines changed

doc/source/whatsnew/v0.24.0.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,7 @@ update the ``ExtensionDtype._metadata`` tuple to match the signature of your
10411041
- :meth:`Series.unstack` and :meth:`DataFrame.unstack` no longer convert extension arrays to object-dtype ndarrays. Each column in the output ``DataFrame`` will now have the same dtype as the input (:issue:`23077`).
10421042
- Bug when grouping :meth:`Dataframe.groupby()` and aggregating on ``ExtensionArray`` it was not returning the actual ``ExtensionArray`` dtype (:issue:`23227`).
10431043
- A default repr for :class:`ExtensionArray` is now provided (:issue:`23601`).
1044+
- Bug in :func:`pandas.merge` when merging on an Integer extension array (:issue:`23020`)
10441045

10451046
.. _whatsnew_0240.api.incompatibilities:
10461047

@@ -1635,12 +1636,6 @@ Sparse
16351636
- Bug in :meth:`SparseArray.nonzero` and :meth:`SparseDataFrame.dropna` returning shifted/incorrect results (:issue:`21172`)
16361637
- Bug in :meth:`DataFrame.apply` where dtypes would lose sparseness (:issue:`23744`)
16371638

1638-
IntegerArray
1639-
^^^^^^^^^^^^
1640-
1641-
- Bug in :func:`pandas.merge` when merging on an Integer extension array (:issue:`23020`)
1642-
1643-
16441639
Build Changes
16451640
^^^^^^^^^^^^^
16461641

pandas/tests/extension/base/reshaping.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,20 @@ def test_merge(self, data, na_value):
173173
dtype=data.dtype)})
174174
self.assert_frame_equal(res, exp[['ext', 'int1', 'key', 'int2']])
175175

176+
# GH 23020
177+
df1 = pd.DataFrame({'ext': data[:3],
178+
'key': pd.Series([1, 2, np.nan], dtype='Int64')})
179+
180+
res = pd.merge(df1, df1, on='key')
181+
182+
exp = pd.DataFrame(
183+
{'key': pd.Series([1, 2, np.nan], dtype='Int64'),
184+
'ext_x': data._from_sequence(data[:3], dtype=data.dtype),
185+
'ext_y': data._from_sequence(data[:3], dtype=data.dtype)})
186+
187+
self.assert_frame_equal(res, exp[['ext_x', 'key', 'ext_y']],
188+
check_dtype=True)
189+
176190
@pytest.mark.parametrize("columns", [
177191
["A", "B"],
178192
pd.MultiIndex.from_tuples([('A', 'a'), ('A', 'b')],
@@ -237,11 +251,3 @@ def test_unstack(self, data, index, obj):
237251
result = result.astype(object)
238252

239253
self.assert_frame_equal(result, expected)
240-
241-
def test_merge_on_int_array(self, df_merge_on_int_array):
242-
# GH 23020
243-
result = pd.merge(df_merge_on_int_array, df_merge_on_int_array, on='A')
244-
expected = pd.DataFrame({'A': pd.Series([1, 2, np.nan], dtype='Int64'),
245-
'B_x': 1,
246-
'B_y': 1})
247-
self.assert_frame_equal(result, expected, check_dtype=True)

pandas/tests/extension/conftest.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import pandas as pd
2-
import numpy as np
31
import operator
42

53
import pytest
@@ -110,9 +108,3 @@ def data_for_grouping():
110108
def box_in_series(request):
111109
"""Whether to box the data in a Series"""
112110
return request.param
113-
114-
115-
@pytest.fixture
116-
def df_merge_on_int_array():
117-
return pd.DataFrame({'A': pd.Series([1, 2, np.nan], dtype='Int64'),
118-
'B': 1})

0 commit comments

Comments
 (0)