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