@@ -2674,7 +2674,7 @@ def get_indexer_for(self, target, **kwargs):
2674
2674
2675
2675
Parameters
2676
2676
----------
2677
- data : dict
2677
+ data : { dict, DictWithoutMissing}
2678
2678
The dictionary from which to extract the values
2679
2679
2680
2680
Returns
@@ -2726,43 +2726,36 @@ def groupby(self, values):
2726
2726
2727
2727
return result
2728
2728
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)
2731
2732
2732
2733
Parameters
2733
2734
----------
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
2737
2739
2738
2740
Returns
2739
2741
-------
2740
- applied : Union[ Index, MultiIndex] , inferred
2742
+ applied : { Index, MultiIndex} , inferred
2741
2743
The output of the mapping function applied to the index.
2742
2744
If the function returns a tuple with more than one element
2743
2745
a MultiIndex will be returned.
2744
2746
2745
2747
"""
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 )
2758
2748
2749
+ from .multi import MultiIndex
2750
+ new_values = super (Index , self )._map_values (
2751
+ self .values , arg , na_action = na_action )
2759
2752
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 ,
2762
2755
names = attributes .get ('name' ))
2763
2756
2764
2757
attributes ['copy' ] = False
2765
- return Index (mapped_values , ** attributes )
2758
+ return Index (new_values , ** attributes )
2766
2759
2767
2760
def isin (self , values , level = None ):
2768
2761
"""
0 commit comments