Skip to content

Commit

Permalink
TST: Adding map test for dict with np.nan key [Ref 17648] (pandas-dev…
Browse files Browse the repository at this point in the history
  • Loading branch information
sofiane87 authored and WillAyd committed Nov 3, 2019
1 parent 11f1002 commit 7403ae0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pandas/tests/series/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,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__,
Expand Down

0 comments on commit 7403ae0

Please sign in to comment.