@@ -955,22 +955,15 @@ def map_f(values, f):
955955 arg = lambda x : dict_with_default [x ]
956956 else :
957957 # Dictionary does not have a default. Thus it's safe to
958- # convert to an Index for efficiency.
959- from pandas import Index
960- idx = Index (arg .keys ())
961- # Cast to dict so we can get values using lib.fast_multiget
962- # if this is a dict subclass (GH #15999)
963- map_values = idx ._get_values_from_dict (dict (arg ))
964- arg = idx
965- elif isinstance (arg , ABCSeries ):
966- map_values = arg .values
967- arg = arg .index
968-
969- if map_values is not None :
958+ # convert to an Series for efficiency.
959+ from pandas import Series
960+ arg = Series (arg , index = arg .keys ())
961+
962+ if isinstance (arg , ABCSeries ):
970963 # Since values were input this means we came from either
971964 # a dict or a series and arg should be an index
972- indexer = arg .get_indexer (values )
973- new_values = algorithms .take_1d (map_values , indexer )
965+ indexer = arg .index . get_indexer (values )
966+ new_values = algorithms .take_1d (arg . _values , indexer )
974967 else :
975968 # arg is a function
976969 new_values = map_f (values , arg )
0 commit comments