Skip to content

Commit 19f6f4c

Browse files
committed
map Categorical with Series
1 parent c3d692c commit 19f6f4c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pandas/tests/apply/test_series_apply.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -649,12 +649,15 @@ def test_map_defaultdict_ignore_na():
649649
tm.assert_series_equal(result, expected)
650650

651651

652-
def test_map_categorical_na_ignore():
652+
@pytest.mark.parametrize(
653+
"na_action, expected",
654+
[(None, Series([10.0, 42.0, np.nan])), ("ignore", Series([10, np.nan, np.nan]))],
655+
)
656+
def test_map_categorical_na_ignore(na_action, expected):
653657
# GH#47527
654-
values = pd.Categorical([1, np.nan, 2], categories=[10, 1])
658+
values = pd.Categorical([1, np.nan, 2], categories=[10, 1, 2])
655659
ser = Series(values)
656-
result = ser.map({1: 10, np.nan: 42})
657-
expected = Series([10, np.nan, np.nan])
660+
result = ser.map({1: 10, np.nan: 42}, na_action=na_action)
658661
tm.assert_series_equal(result, expected)
659662

660663

0 commit comments

Comments
 (0)