Skip to content

loc: label index does not raise KeyError with list of ints #3449

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

Closed
kyleam opened this issue Apr 24, 2013 · 2 comments · Fixed by #3451
Closed

loc: label index does not raise KeyError with list of ints #3449

kyleam opened this issue Apr 24, 2013 · 2 comments · Fixed by #3451
Assignees
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@kyleam
Copy link
Contributor

kyleam commented Apr 24, 2013

I didn't expect the last line of code to pass.

import numpy as np
import pandas as pd

pd.__version__
#[Out]# '0.12.0.dev-5c3ccdb'

np.random.seed(33)
df = pd.DataFrame(np.random.random((3, 3)),
                  index=['a', 'b', 'c'],
                  columns=['e', 'f', 'g'])

# raise a KeyError?
df.loc[[1, 2], [1, 2]]
#[Out]#           f         g
#[Out]# b  0.870396  0.185040
#[Out]# c  0.953252  0.680451

Being strictly label based, shouldn't loc fail when it doesn't find 1 or 2 as a label?

@ghost ghost assigned jreback Apr 24, 2013
@jreback
Copy link
Contributor

jreback commented Apr 24, 2013

that looks correct (in that it should raise), I think the comparison is backwards (and appartenly I am not testing it well enought).....marking this as a bug...thanks

@jreback
Copy link
Contributor

jreback commented Apr 25, 2013

closes by #3449

@jreback jreback closed this as completed Apr 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants