From 1ab756e1029501ccdf751c5fed622da2956aeabe Mon Sep 17 00:00:00 2001 From: sofiane87 Date: Sat, 2 Nov 2019 17:17:29 +0000 Subject: [PATCH] TST: Adding map test for dict with np.nan key [Ref 17648] --- pandas/tests/series/test_apply.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandas/tests/series/test_apply.py b/pandas/tests/series/test_apply.py index e56294669a546..971ce5b18c323 100644 --- a/pandas/tests/series/test_apply.py +++ b/pandas/tests/series/test_apply.py @@ -581,6 +581,14 @@ def test_map_defaultdict(self): expected = Series(["stuff", "blank", "blank"], index=["a", "b", "c"]) tm.assert_series_equal(result, expected) + def test_map_dict_na_key(self): + # https://github.com/pandas-dev/pandas/issues/17648 + # Checks that np.nan key is appropriately mapped + s = Series([1, 2, np.nan]) + expected = Series(["a", "b", "c"]) + result = s.map({1: "a", 2: "b", np.nan: "c"}) + tm.assert_series_equal(result, expected) + def test_map_dict_subclass_with_missing(self): """ Test Series.map with a dictionary subclass that defines __missing__,