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

BUG: various categorical fixes (GH8626) #8652

Merged
merged 1 commit into from
Oct 28, 2014
Merged

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Oct 27, 2014

BUG: coerce Categorical in record array creation (GH8626)
BUG: Categorical not created properly with to_frame() from Series (GH8626)
BUG: handle astype with passed pd.Categorical (GH8626)

closes #8626

lambda x: x.astype('object').astype('category'),
lambda x: x.astype('object').astype(com.CategoricalDtype()),
lambda x: x.astype(pd.Categorical),
lambda x: x.astype('object').astype(pd.Categorical)]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it actually needed that we support this? Should't it rather raise?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Categorical is somewhat the ndarray with category dtype, this seems a bit like doing

df.astype(np.ndarray)

which seems strange.

But I actually tried this, and this also does not fail but converts all values to object. Is this intended? Or also a bug/case that should raise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could raise and and technically we should as Categorical is NOT a dtype
ok will switch back as it is really stretching the API

@jreback jreback force-pushed the to_cat branch 2 times, most recently from 99de43a to 44a0f48 Compare October 27, 2014 22:18
BUG: Categorical not created properly with to_frame() from Series (GH8626)
BUG: handle astype with passed pd.Categorical (GH8626)
jreback added a commit that referenced this pull request Oct 28, 2014
BUG: various categorical fixes (GH8626)
@jreback jreback merged commit abac52c into pandas-dev:master Oct 28, 2014
@jreback jreback modified the milestones: 0.15.2, 0.15.1 Oct 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Categorical Categorical Data Type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: DataFrame.to_records, DataFrame constructor broken for categoricals
2 participants