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 a categorial column returns a DataFrame #12998

Closed
rsdenijs opened this issue Apr 26, 2016 · 2 comments
Closed

Selecting a categorial column returns a DataFrame #12998

rsdenijs opened this issue Apr 26, 2016 · 2 comments
Labels
Bug Categorical Categorical Data Type Duplicate Report Duplicate issue or pull request Indexing Related to indexing on series/frames, not to indexes themselves

Comments

@rsdenijs
Copy link

I am not 100% sure if this is a bug, but it generates very unexpected behaviour!
Essentially, if columns are of type Categorical, selecting a single one using df[column_name] a DataFrame is returned, unlike for columns of other types, for which a Series would be returned.

Code Sample, a copy-pastable example if possible

print pd.DataFrame([[1,2]], columns=['a','b'])['a'].__class__
print pd.DataFrame([[1,2]], columns=pd.Categorical(['a','b']))['a'].__class__

produces


<class 'pandas.core.series.Series'>  <--- Ok....
<class 'pandas.core.frame.DataFrame'> <----- What?!

Expected Output

<class 'pandas.core.series.Series'>
<class 'pandas.core.series.Series'>

output of pd.show_versions()

pandas: 0.18.0

@jreback
Copy link
Contributor

jreback commented Apr 26, 2016

this was fixed by #12531 in forthcoming 0.18.1

@jreback jreback closed this as completed Apr 26, 2016
@jreback jreback added Bug Indexing Related to indexing on series/frames, not to indexes themselves Categorical Categorical Data Type Duplicate Report Duplicate issue or pull request labels Apr 26, 2016
@jreback jreback added this to the No action milestone Apr 26, 2016
@rsdenijs
Copy link
Author

Ahh, i did not see that issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Categorical Categorical Data Type Duplicate Report Duplicate issue or pull request Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

No branches or pull requests

2 participants