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

Curious: df.ix[False] returns the first row #2199

Closed
ghost opened this issue Nov 8, 2012 · 6 comments
Closed

Curious: df.ix[False] returns the first row #2199

ghost opened this issue Nov 8, 2012 · 6 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Nov 8, 2012

In [21]: df=pd.DataFrame({"a":[1,2,3]})
    ...: df.ix[False]
Out[21]: 
a    1
Name: 0

Don't know if this is a bug or intentiional.

@wesm
Copy link
Member

wesm commented Nov 8, 2012

Getting coerced to 0 I guess. Buglet

@changhiskhan
Copy link
Contributor

In [9]: com.is_integer(True)
Out[9]: True

@cpcloud
Copy link
Member

cpcloud commented Nov 8, 2012

In the Python source (Include/boolobject.h I believe) you have,

typedef PyIntObject PyBoolObject;

thus it is a subclass of int and will be auto-coerced to 0.

@wesm wesm closed this as completed in d5d31f1 Nov 9, 2012
@ghost
Copy link
Author

ghost commented Nov 9, 2012

FAIL: test_getitem_setitem_ix_bool_keyerror (pandas.tests.test_frame.TestDataFrame)

Traceback (most recent call last):
File "/home/user1/src/pandas/pandas/tests/test_frame.py", line 1115, in test_getitem_setitem_ix_bool_keyerror
self.assertRaises(KeyError, df.ix.getitem, False)
AssertionError: KeyError not raised

@wesm
Copy link
Member

wesm commented Nov 9, 2012

That's interesting. Did you rebuild the C extensions?

@ghost
Copy link
Author

ghost commented Nov 9, 2012

that was it. thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants