Skip to content

Commit 293193e

Browse files
committed
2nd change after review
1 parent 4db97ad commit 293193e

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

doc/source/whatsnew/v0.24.0.txt

+2-6
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,8 @@ update the ``ExtensionDtype._metadata`` tuple to match the signature of your
858858
- :meth:`DataFrame.stack` no longer converts to object dtype for DataFrames where each column has the same extension dtype. The output Series will have the same dtype as the columns (:issue:`23077`).
859859
- :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`).
860860
- Bug when grouping :meth:`Dataframe.groupby()` and aggregating on ``ExtensionArray`` it was not returning the actual ``ExtensionArray`` dtype (:issue:`23227`).
861+
- :meth:`Series.unstack` no longer converts extension arrays to object-dtype ndarrays. The output ``DataFrame`` will now have the same dtype as the input. This changes behavior for Categorical and Sparse data (:issue:`23077`).
862+
- Bug in :func:`pandas.merge` when merging on an Integer extension array (:issue:`23020`)
861863

862864
.. _whatsnew_0240.api.incompatibilities:
863865

@@ -1360,12 +1362,6 @@ Sparse
13601362
- Bug in unary inversion operator (``~``) on a ``SparseSeries`` with boolean values. The performance of this has also been improved (:issue:`22835`)
13611363
- Bug in :meth:`SparseArary.unique` not returning the unique values (:issue:`19595`)
13621364

1363-
IntegerArray
1364-
^^^^^^^^^^^^
1365-
1366-
- Bug in :func:`pandas.merge` when merging on an Integer extension array (:issue:`23020`)
1367-
1368-
13691365
Build Changes
13701366
^^^^^^^^^^^^^
13711367

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)