Skip to content

Commit 8caf370

Browse files
authored
TST: Check map function works with StringDtype (#40823) (#41723)
1 parent f1c886d commit 8caf370

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/apply/test_series_apply.py

+14
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@ def func(x):
115115
ser.apply(func)
116116

117117

118+
def test_series_map_stringdtype(any_string_dtype):
119+
# map test on StringDType, GH#40823
120+
ser1 = Series(
121+
data=["cat", "dog", "rabbit"],
122+
index=["id1", "id2", "id3"],
123+
dtype=any_string_dtype,
124+
)
125+
ser2 = Series(data=["id3", "id2", "id1", "id7000"], dtype=any_string_dtype)
126+
result = ser2.map(ser1)
127+
expected = Series(data=["rabbit", "dog", "cat", pd.NA], dtype=any_string_dtype)
128+
129+
tm.assert_series_equal(result, expected)
130+
131+
118132
def test_apply_box():
119133
# ufunc will not be boxed. Same test cases as the test_map_box
120134
vals = [pd.Timestamp("2011-01-01"), pd.Timestamp("2011-01-02")]

0 commit comments

Comments
 (0)