Skip to content

Commit 5b1ca5b

Browse files
committed
add test to make sure dictionaries with missing keys work
1 parent cf6c831 commit 5b1ca5b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pandas/tests/indexes/test_base.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,6 @@ def test_map_with_series_all_indices(self):
830830
self.assert_numpy_array_equal(expected.values.get_values(), output.values.get_values())
831831
self.assert_equal(expected.name, output.name)
832832

833-
834833
for name in list(set(self.indices.keys()) - set(special)):
835834
cur_index = self.indices[name]
836835
expected = Index(np.arange(len(cur_index), 0, -1))
@@ -850,12 +849,16 @@ def test_map_with_categorical_series(self):
850849
exp = Index(["odd", "even", "odd", np.nan])
851850
self.assert_index_equal(a.map(c), exp)
852851

853-
def test_map_with_series_missing_values(self):
852+
def test_map_with_non_function_missing_values(self):
854853
# GH 12756
855854
expected = Index([2., np.nan, 'foo'])
855+
input = Index([2, 1, 0])
856+
856857
mapper = Series(['foo', 2., 'baz'], index=[0, 2, -1])
857-
output = Index([2, 1, 0]).map(mapper)
858-
self.assert_index_equal(output, expected)
858+
self.assert_index_equal(expected, input.map(mapper))
859+
860+
mapper = {0: 'foo', 2: 2.0, -1: 'baz'}
861+
self.assert_index_equal(expected, input.map(mapper))
859862

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

0 commit comments

Comments
 (0)