New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataFrame indices can't map through dictionaries or series #12756

azevedoph-check24 opened this Issue Mar 31, 2016 · 3 comments


None yet
3 participants

azevedoph-check24 commented Mar 31, 2016

A DataFrame index has the map function, which expects a mapper. However, unlike mapping a Series, it only accepts callables, and won't work when mapping through dictionaries or series.

Code Sample:

df = pd.DataFrame({'col1': range(5)})
d = {0: 'zero', 1: 'one', 2: 'two', 3: 'three', 4: 'four'} # perfectly valid # TypeError: 'dict' object is not callable
s = pd.Series(d) # perfectly valid # TypeError: 'Series' object is not callable

Expected Output:

I would expect the same output for and, or at least that it returns an nparray with the mapped values, as it does when we do pass a callable, but not that it breaks like it does.

output of pd.show_versions():


commit: None
python-bits: 64
OS: Linux
OS-release: 3.16.0-67-generic
machine: x86_64
processor: x86_64
byteorder: little

pandas: 0.18.0
nose: 1.3.7
pip: 8.1.1
setuptools: 20.6.6
Cython: 0.23.5
numpy: 1.11.0
scipy: 0.17.0
statsmodels: 0.6.1
xarray: None
IPython: 4.1.2
sphinx: 1.4
patsy: 0.4.1
dateutil: 2.5.2
pytz: 2016.3
blosc: None
bottleneck: None
tables: None
numexpr: 2.5.1
matplotlib: 1.5.1
openpyxl: 2.3.4
xlrd: 0.9.4
xlwt: None
xlsxwriter: None
lxml: 3.6.0
bs4: None
html5lib: 0.9999999
httplib2: 0.9.2
apiclient: None
sqlalchemy: 1.0.12
pymysql: None
psycopg2: 2.6.1 (dt dec pq3 ext lo64)
jinja2: 2.8
boto: 2.39.0


This comment has been minimized.


jreback commented Mar 31, 2016

@sinhrks and I had this exact discussion very recently: #12532 (comment)

so yes, these should be unified, but are a bit non-trivial to do so. welcome to have pull-requests!


This comment has been minimized.


sinhrks commented Mar 31, 2016

Yes, currently I think should be fixed prior to #12532. Will take a look.


This comment has been minimized.


jreback commented Apr 1, 2016

xref #12766

@jreback jreback modified the milestones: Next Major Release, 0.22.0 Nov 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment