@@ -5753,6 +5753,35 @@ def test_map(self):
57535753 result = self .ts .map (lambda x : x * 2 )
57545754 self .assert_numpy_array_equal (result , self .ts * 2 )
57555755
5756+ # GH 10324
5757+ a = Series ([1 , 2 , 3 , 4 ])
5758+ b = Series (["even" , "odd" , "even" , "odd" ], dtype = "category" )
5759+ c = Series (["even" , "odd" , "even" , "odd" ])
5760+
5761+ exp = Series (["odd" , "even" , "odd" , np .nan ], dtype = "category" )
5762+ self .assert_series_equal (a .map (b ), exp )
5763+ exp = Series (["odd" , "even" , "odd" , np .nan ])
5764+ self .assert_series_equal (a .map (c ), exp )
5765+
5766+ a = Series (['a' , 'b' , 'c' , 'd' ])
5767+ b = Series ([1 , 2 , 3 , 4 ], index = pd .CategoricalIndex (['b' , 'c' , 'd' , 'e' ]))
5768+ c = Series ([1 , 2 , 3 , 4 ], index = Index (['b' , 'c' , 'd' , 'e' ]))
5769+
5770+ exp = Series ([np .nan , 1 , 2 , 3 ])
5771+ self .assert_series_equal (a .map (b ), exp )
5772+ exp = Series ([np .nan , 1 , 2 , 3 ])
5773+ self .assert_series_equal (a .map (c ), exp )
5774+
5775+ a = Series (['a' , 'b' , 'c' , 'd' ])
5776+ b = Series (['B' , 'C' , 'D' , 'E' ], dtype = 'category' ,
5777+ index = pd .CategoricalIndex (['b' , 'c' , 'd' , 'e' ]))
5778+ c = Series (['B' , 'C' , 'D' , 'E' ], index = Index (['b' , 'c' , 'd' , 'e' ]))
5779+
5780+ exp = Series ([np .nan , 'B' , 'C' , 'D' ], dtype = 'category' )
5781+ self .assert_series_equal (a .map (b ), exp )
5782+ exp = Series ([np .nan , 'B' , 'C' , 'D' ])
5783+ self .assert_series_equal (a .map (c ), exp )
5784+
57565785 def test_map_compat (self ):
57575786 # related GH 8024
57585787 s = Series ([True ,True ,False ],index = [1 ,2 ,3 ])
0 commit comments