Skip to content

Commit fd5d6d1

Browse files
sofiane87proost
authored andcommitted
TST: Adding map test for dict with np.nan key [Ref 17648] (pandas-dev#29367)
1 parent 2fbb809 commit fd5d6d1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/tests/series/test_apply.py

+8
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,14 @@ def test_map_defaultdict(self):
587587
expected = Series(["stuff", "blank", "blank"], index=["a", "b", "c"])
588588
tm.assert_series_equal(result, expected)
589589

590+
def test_map_dict_na_key(self):
591+
# https://github.com/pandas-dev/pandas/issues/17648
592+
# Checks that np.nan key is appropriately mapped
593+
s = Series([1, 2, np.nan])
594+
expected = Series(["a", "b", "c"])
595+
result = s.map({1: "a", 2: "b", np.nan: "c"})
596+
tm.assert_series_equal(result, expected)
597+
590598
def test_map_dict_subclass_with_missing(self):
591599
"""
592600
Test Series.map with a dictionary subclass that defines __missing__,

0 commit comments

Comments
 (0)