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

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

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

Comments

@kyleam
Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

commented Apr 25, 2013

closes by #3449

@jreback jreback closed this Apr 25, 2013

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