@@ -2674,7 +2674,7 @@ def get_indexer_for(self, target, **kwargs):
26742674
26752675 Parameters
26762676 ----------
2677- data : dict
2677+ data : { dict, DictWithoutMissing}
26782678 The dictionary from which to extract the values
26792679
26802680 Returns
@@ -2726,43 +2726,36 @@ def groupby(self, values):
27262726
27272727 return result
27282728
2729- def map (self , mapper ):
2730- """Apply mapper function to an index.
2729+ def map (self , arg , na_action = None ):
2730+ """Map values of Series using input correspondence (which can be a
2731+ dict, Series, or function)
27312732
27322733 Parameters
27332734 ----------
2734- mapper : {callable, dict, Series}
2735- Function to be applied or input correspondence object.
2736- dict and Series support new in 0.20.0.
2735+ arg : function, dict, or Series
2736+ na_action : {None, 'ignore'}
2737+ If 'ignore', propagate NA values, without passing them to the
2738+ mapping function
27372739
27382740 Returns
27392741 -------
2740- applied : Union[ Index, MultiIndex] , inferred
2742+ applied : { Index, MultiIndex} , inferred
27412743 The output of the mapping function applied to the index.
27422744 If the function returns a tuple with more than one element
27432745 a MultiIndex will be returned.
27442746
27452747 """
2746- from .multi import MultiIndex
2747-
2748- if isinstance (mapper , ABCSeries ):
2749- indexer = mapper .index .get_indexer (self .values )
2750- mapped_values = algos .take_1d (mapper .values , indexer )
2751- elif isinstance (mapper , dict ):
2752- idx = Index (mapper .keys ())
2753- data = idx ._get_values_from_dict (mapper )
2754- indexer = idx .get_indexer (self .values )
2755- mapped_values = algos .take_1d (data , indexer )
2756- else :
2757- mapped_values = self ._arrmap (self .values , mapper )
27582748
2749+ from .multi import MultiIndex
2750+ new_values = super (Index , self )._map_values (
2751+ self .values , arg , na_action = na_action )
27592752 attributes = self ._get_attributes_dict ()
2760- if mapped_values .size and isinstance (mapped_values [0 ], tuple ):
2761- return MultiIndex .from_tuples (mapped_values ,
2753+ if new_values .size and isinstance (new_values [0 ], tuple ):
2754+ return MultiIndex .from_tuples (new_values ,
27622755 names = attributes .get ('name' ))
27632756
27642757 attributes ['copy' ] = False
2765- return Index (mapped_values , ** attributes )
2758+ return Index (new_values , ** attributes )
27662759
27672760 def isin (self , values , level = None ):
27682761 """
0 commit comments