@@ -2827,7 +2827,7 @@ def get_indexer_for(self, target, **kwargs):
2827
2827
2828
2828
Parameters
2829
2829
----------
2830
- data : dict
2830
+ data : { dict, DictWithoutMissing}
2831
2831
The dictionary from which to extract the values
2832
2832
2833
2833
Returns
@@ -2879,43 +2879,36 @@ def groupby(self, values):
2879
2879
2880
2880
return result
2881
2881
2882
- def map (self , mapper ):
2883
- """Apply mapper function to an index.
2882
+ def map (self , arg , na_action = None ):
2883
+ """Map values of Series using input correspondence (which can be a
2884
+ dict, Series, or function)
2884
2885
2885
2886
Parameters
2886
2887
----------
2887
- mapper : {callable, dict, Series}
2888
- Function to be applied or input correspondence object.
2889
- dict and Series support new in 0.20.0.
2888
+ arg : function, dict, or Series
2889
+ na_action : {None, 'ignore'}
2890
+ If 'ignore', propagate NA values, without passing them to the
2891
+ mapping function
2890
2892
2891
2893
Returns
2892
2894
-------
2893
- applied : Union[ Index, MultiIndex] , inferred
2895
+ applied : { Index, MultiIndex} , inferred
2894
2896
The output of the mapping function applied to the index.
2895
2897
If the function returns a tuple with more than one element
2896
2898
a MultiIndex will be returned.
2897
2899
2898
2900
"""
2899
- from .multi import MultiIndex
2900
-
2901
- if isinstance (mapper , ABCSeries ):
2902
- indexer = mapper .index .get_indexer (self .values )
2903
- mapped_values = algos .take_1d (mapper .values , indexer )
2904
- elif isinstance (mapper , dict ):
2905
- idx = Index (mapper .keys ())
2906
- data = idx ._get_values_from_dict (mapper )
2907
- indexer = idx .get_indexer (self .values )
2908
- mapped_values = algos .take_1d (data , indexer )
2909
- else :
2910
- mapped_values = self ._arrmap (self .values , mapper )
2911
2901
2902
+ from .multi import MultiIndex
2903
+ new_values = super (Index , self )._map_values (
2904
+ self .values , arg , na_action = na_action )
2912
2905
attributes = self ._get_attributes_dict ()
2913
- if mapped_values .size and isinstance (mapped_values [0 ], tuple ):
2914
- return MultiIndex .from_tuples (mapped_values ,
2906
+ if new_values .size and isinstance (new_values [0 ], tuple ):
2907
+ return MultiIndex .from_tuples (new_values ,
2915
2908
names = attributes .get ('name' ))
2916
2909
2917
2910
attributes ['copy' ] = False
2918
- return Index (mapped_values , ** attributes )
2911
+ return Index (new_values , ** attributes )
2919
2912
2920
2913
def isin (self , values , level = None ):
2921
2914
"""
0 commit comments