Skip to content

Commit 98245ec

Browse files
committed
2nd change after review
1 parent 19f5a8c commit 98245ec

File tree

3 files changed

+15
-22
lines changed

3 files changed

+15
-22
lines changed

doc/source/whatsnew/v0.24.0.rst

+1-6
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,7 @@ update the ``ExtensionDtype._metadata`` tuple to match the signature of your
10031003
- :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`).
10041004
- Bug when grouping :meth:`Dataframe.groupby()` and aggregating on ``ExtensionArray`` it was not returning the actual ``ExtensionArray`` dtype (:issue:`23227`).
10051005
- A default repr for :class:`ExtensionArray` is now provided (:issue:`23601`).
1006+
- Bug in :func:`pandas.merge` when merging on an Integer extension array (:issue:`23020`)
10061007

10071008
.. _whatsnew_0240.api.incompatibilities:
10081009

@@ -1564,12 +1565,6 @@ Sparse
15641565
- Bug in :meth:`SparseArray.nonzero` and :meth:`SparseDataFrame.dropna` returning shifted/incorrect results (:issue:`21172`)
15651566
- Bug in :meth:`DataFrame.apply` where dtypes would lose sparseness (:issue:`23744`)
15661567

1567-
IntegerArray
1568-
^^^^^^^^^^^^
1569-
1570-
- Bug in :func:`pandas.merge` when merging on an Integer extension array (:issue:`23020`)
1571-
1572-
15731568
Build Changes
15741569
^^^^^^^^^^^^^
15751570

pandas/tests/extension/base/reshaping.py

+14-8
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

-8
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
@@ -106,9 +104,3 @@ def data_for_grouping():
106104
def box_in_series(request):
107105
"""Whether to box the data in a Series"""
108106
return request.param
109-
110-
111-
@pytest.fixture
112-
def df_merge_on_int_array():
113-
return pd.DataFrame({'A': pd.Series([1, 2, np.nan], dtype='Int64'),
114-
'B': 1})

0 commit comments

Comments
 (0)