Skip to content

Commit bf85840

Browse files
committed
TST: Add updated test on Series (pandas-dev#40823).
Checking map function on two series of data type StringDType. Series data is arbitrary.
1 parent d8347c8 commit bf85840

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

pandas/tests/apply/test_series_apply.py

+6-13
Original file line numberDiff line numberDiff line change
@@ -117,23 +117,16 @@ def func(x):
117117

118118
def test_series_map_stringdtype():
119119
# map test on StringDType, GH#40823
120-
df1 = DataFrame(
121-
{"col1": [pd.NA, "foo", "bar"]},
120+
ser1 = Series(
121+
data=["cat", "dog", "rabbit"],
122122
index=["id1", "id2", "id3"],
123123
dtype=pd.StringDtype(),
124124
)
125+
ser2 = Series(data=["id3", "id2", "id1", "id7000"], dtype=pd.StringDtype())
126+
result = ser2.map(ser1)
127+
expected = Series(data=["rabbit", "dog", "cat", pd.NA], dtype=pd.StringDtype())
125128

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)
129+
tm.assert_series_equal(result, expected)
137130

138131

139132
def test_apply_box():

0 commit comments

Comments
 (0)