Skip to content

Commit 19621e6

Browse files
committed
Test merge with EA as key and open a special case
1 parent 29e820d commit 19621e6

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

pandas/tests/extension/base/reshaping.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,17 @@ def test_merge(self, data, na_value):
173173
dtype=data.dtype)})
174174
self.assert_frame_equal(res, exp[['ext', 'int1', 'key', 'int2']])
175175

176-
@pytest.mark.parametrize("dtypes", ["Int8", "Int16", "Int32", "Int64",
177-
"UInt8", "UInt16", "UInt32", "UInt64"])
178-
def test_merge_on_int_array(self, data, dtypes):
179-
# GH 23020
180-
df1 = pd.DataFrame({'ext': data[:3],
181-
'key': pd.Series([1, 2, np.nan], dtype=dtypes)})
176+
def test_merge_on_extension_array(self, data):
177+
# GH 23020
178+
df1 = pd.DataFrame({'ext': [1, 2, 3],
179+
'key': data[:3]})
180+
182181
res = pd.merge(df1, df1, on='key')
183182

184183
exp = pd.DataFrame(
185-
{'key': pd.Series([1, 2, np.nan], dtype=dtypes),
186-
'ext_x': data._from_sequence(data[:3], dtype=data.dtype),
187-
'ext_y': data._from_sequence(data[:3], dtype=data.dtype)})
184+
{'key': data[:3],
185+
'ext_x': [1, 2, 3],
186+
'ext_y': [1, 2, 3]})
188187

189188
self.assert_frame_equal(res, exp[['ext_x', 'key', 'ext_y']],
190189
check_dtype=True)

pandas/tests/reshape/merge/test_merge.py

+10
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,16 @@ def test_merging_with_bool_or_int_cateorical_column(self, category_column,
13261326
CDT(categories, ordered=ordered))
13271327
assert_frame_equal(expected, result)
13281328

1329+
def test_merge_on_int_array(self):
1330+
# GH 23020
1331+
df = pd.DataFrame({'A': pd.Series([1, 2, np.nan], dtype='Int64'),
1332+
'B': 1})
1333+
result = pd.merge(df, df, on='A')
1334+
expected = pd.DataFrame({'A': pd.Series([1, 2, np.nan], dtype='Int64'),
1335+
'B_x': 1,
1336+
'B_y': 1})
1337+
assert_frame_equal(result, expected, check_dtype=True)
1338+
13291339

13301340
@pytest.fixture
13311341
def left_df():

0 commit comments

Comments
 (0)