Skip to content

Commit d8347c8

Browse files
committed
TST: Add new test to pandas/tests/apply/test_series_apply.py
1 parent c707f1b commit d8347c8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pandas/tests/apply/test_series_apply.py

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

117117

118+
def test_series_map_stringdtype():
119+
# map test on StringDType, GH#40823
120+
df1 = DataFrame(
121+
{"col1": [pd.NA, "foo", "bar"]},
122+
index=["id1", "id2", "id3"],
123+
dtype=pd.StringDtype(),
124+
)
125+
126+
df2 = DataFrame({"id": ["id4", "id2", "id1"]}, dtype=pd.StringDtype())
127+
128+
df2["col1"] = df2["id"].map(df1["col1"])
129+
130+
result = df2
131+
expected = DataFrame(
132+
{"id": ["id4", "id2", "id1"], "col1": [pd.NA, "foo", pd.NA]},
133+
dtype=pd.StringDtype(),
134+
)
135+
136+
tm.assert_frame_equal(result, expected)
137+
138+
118139
def test_apply_box():
119140
# ufunc will not be boxed. Same test cases as the test_map_box
120141
vals = [pd.Timestamp("2011-01-01"), pd.Timestamp("2011-01-02")]

0 commit comments

Comments
 (0)