We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d8347c8 commit bf85840Copy full SHA for bf85840
pandas/tests/apply/test_series_apply.py
@@ -117,23 +117,16 @@ def func(x):
117
118
def test_series_map_stringdtype():
119
# map test on StringDType, GH#40823
120
- df1 = DataFrame(
121
- {"col1": [pd.NA, "foo", "bar"]},
+ ser1 = Series(
+ data=["cat", "dog", "rabbit"],
122
index=["id1", "id2", "id3"],
123
dtype=pd.StringDtype(),
124
)
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())
128
- df2 = DataFrame({"id": ["id4", "id2", "id1"]}, dtype=pd.StringDtype())
-
- 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)
+ tm.assert_series_equal(result, expected)
137
138
139
def test_apply_box():
0 commit comments