Skip to content

Index.map should allow dict as argument #13517

Closed
@evanpw

Description

@evanpw

Series.map works when passed a dict, but Index.map doesn't:

>>> s = pd.Series(['a', 'b', 'c', 'd'], index=['a', 'b', 'c', 'd'])
>>> d = {'a': 0, 'b': 1, 'c': 2, 'd': 3}
>>> s.map(d)
a    0
b    1
c    2
d    3
dtype: int64
>>> s.index.map(d)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/evanpw/Workspace/pandas/pandas/indexes/base.py", line 2305, in map
    return self._arrmap(self.values, mapper)
  File "pandas/src/generated.pyx", line 2356, in pandas.algos.arrmap_object (pandas/algos.c:70221)
TypeError: 'dict' object is not callable

PR to follow shortly

Metadata

Metadata

Assignees

No one assigned

    Labels

    Dtype ConversionsUnexpected or buggy dtype conversionsDuplicate ReportDuplicate issue or pull requestEnhancementIndexRelated to the Index class or subclasses

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions