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

Selecting same column twice in DataFrame does not work when some columns are bool #5639

Closed
opisthokonta opened this issue Dec 4, 2013 · 1 comment · Fixed by #5640
Closed
Labels
Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@opisthokonta
Copy link

It works fine to select a column twice if the DataFrame does not consists of any columns of dtype bool, but works fine otherwise.

import pandas as pd

#Data with just bool columns
dbool = {'one' : pd.Series([True, True, False], index=['a', 'b', 'c']),
    'two' : pd.Series([False, False, True, False], index=['a', 'b', 'c', 'd']),
    'three': pd.Series([False, True, True, True], index=['a', 'b', 'c', 'd'])}

#No bool columns
dnum = {'four' : pd.Series([1., 2., 3.], index=['a', 'b', 'c']),
    'five' : pd.Series([1., 2., 3., 0.4], index=['a', 'b', 'c', 'd']),
    'six': pd.Series([9., 5., 4., -0.1], index=['a', 'b', 'c', 'd'])}

#data with both bool and non-bool columns
dmixed = {'one' : pd.Series([True, True, False], index=['a', 'b', 'c']),
    'two' : pd.Series([False, False, True, False], index=['a', 'b', 'c', 'd']),
    'three': pd.Series([False, True, True, True], index=['a', 'b', 'c', 'd']),
    'four' : pd.Series([1., 2., 3.], index=['a', 'b', 'c']),
    'five' : pd.Series([1., 2., 3., 0.4], index=['a', 'b', 'c', 'd']),
    'six': pd.Series([9., 5., 4., -0.1], index=['a', 'b', 'c', 'd'])}

dfbool = pd.DataFrame(dbool)
dfnum = pd.DataFrame(dnum)  
dfmixed = pd.DataFrame(dmixed)

#Works fine
dfnum[['four', 'five', 'four']]

#Does not work
dfbool[['one', 'three', 'one']]

#Does not work
dfmixed[['four', 'five', 'four']]
dfmixed[['one', 'three', 'one']]
dfmixed[['one', 'four', 'one']]
@jreback
Copy link
Contributor

jreback commented Dec 4, 2013

thanks for the report...this was a missed case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions 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