Skip to content

Commit

Permalink
TST: Check map function works with StringDtype (#40823) (#41723)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdhsieh authored Jun 2, 2021
1 parent f1c886d commit 8caf370
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pandas/tests/apply/test_series_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ def func(x):
ser.apply(func)


def test_series_map_stringdtype(any_string_dtype):
# map test on StringDType, GH#40823
ser1 = Series(
data=["cat", "dog", "rabbit"],
index=["id1", "id2", "id3"],
dtype=any_string_dtype,
)
ser2 = Series(data=["id3", "id2", "id1", "id7000"], dtype=any_string_dtype)
result = ser2.map(ser1)
expected = Series(data=["rabbit", "dog", "cat", pd.NA], dtype=any_string_dtype)

tm.assert_series_equal(result, expected)


def test_apply_box():
# ufunc will not be boxed. Same test cases as the test_map_box
vals = [pd.Timestamp("2011-01-01"), pd.Timestamp("2011-01-02")]
Expand Down

0 comments on commit 8caf370

Please sign in to comment.