Skip to content

Commit fd72c4f

Browse files
committed
add test to make sure dictionaries with missing keys work
1 parent a718128 commit fd72c4f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pandas/tests/indexes/test_base.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,6 @@ def test_map_with_series_all_indices(self):
828828
self.assert_numpy_array_equal(expected.values.get_values(), output.values.get_values())
829829
self.assert_equal(expected.name, output.name)
830830

831-
832831
for name in list(set(self.indices.keys()) - set(special)):
833832
cur_index = self.indices[name]
834833
expected = Index(np.arange(len(cur_index), 0, -1))
@@ -848,12 +847,16 @@ def test_map_with_categorical_series(self):
848847
exp = Index(["odd", "even", "odd", np.nan])
849848
self.assert_index_equal(a.map(c), exp)
850849

851-
def test_map_with_series_missing_values(self):
850+
def test_map_with_non_function_missing_values(self):
852851
# GH 12756
853852
expected = Index([2., np.nan, 'foo'])
853+
input = Index([2, 1, 0])
854+
854855
mapper = Series(['foo', 2., 'baz'], index=[0, 2, -1])
855-
output = Index([2, 1, 0]).map(mapper)
856-
self.assert_index_equal(output, expected)
856+
self.assert_index_equal(expected, input.map(mapper))
857+
858+
mapper = {0: 'foo', 2: 2.0, -1: 'baz'}
859+
self.assert_index_equal(expected, input.map(mapper))
857860

858861
def test_append_multiple(self):
859862
index = Index(['a', 'b', 'c', 'd', 'e', 'f'])

0 commit comments

Comments
 (0)