Skip to content
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

Incorrect Message in KeyError with MultiIndex #27250

Closed
djbarker opened this issue Jul 5, 2019 · 4 comments

Comments

@djbarker
Copy link

commented Jul 5, 2019

Code Sample

X = pd.DataFrame(dict(A=[1, 1, 1, 2, 2, 2], B=[1, 2, 3, 1, 2, 3], C=[1, 2, 3, 4, 5, 6], D=list("abcdef")))
X = X.set_index(["A", "B", "C"])
X.loc[(1, 1, 2), :] 

Problem description

This correctly throws a KeyError but the message is incorrect, instead of showing "KeyError: (1, 1, 2)" it shows "KeyError: 42"

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Linux
OS-release: 4.18.16-200.fc28.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8

pandas: 0.24.2
pytest: None
pip: 19.1.1
setuptools: 41.0.1
Cython: None
numpy: 1.16.4
scipy: 0.19.1
pyarrow: 0.13.0
xarray: None
IPython: 7.1.1
sphinx: None
patsy: 0.5.1
dateutil: 2.8.0
pytz: 2019.1
blosc: None
bottleneck: None
tables: None
numexpr: 2.6.4
feather: 0.4.0
matplotlib: 2.1.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: 4.3.0
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: 2.7.4 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

@jreback

This comment has been minimized.

Copy link
Contributor

commented Jul 5, 2019

pls try this on master / 0.25.rc0

@djbarker

This comment has been minimized.

Copy link
Author

commented Jul 5, 2019

The download link on the pandas home page appears to be broken. It points to https://pypi.org/project/pandas/0.25.0/#files

@jreback

This comment has been minimized.

Copy link
Contributor

commented Jul 5, 2019

https://github.com/pandas-dev/pandas/releases

this is a release candidate

@djbarker

This comment has been minimized.

Copy link
Author

commented Jul 5, 2019

Thanks. I set-up a fresh conda environment and installed pandas 0.25.0.rc0 and it shows the same incorrect behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.