Skip to content

ENH: Infer Enums as categorical #36819

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

Open
dzimmanck opened this issue Oct 2, 2020 · 2 comments
Open

ENH: Infer Enums as categorical #36819

dzimmanck opened this issue Oct 2, 2020 · 2 comments
Labels
Categorical Categorical Data Type Enhancement

Comments

@dzimmanck
Copy link

dzimmanck commented Oct 2, 2020

Is your feature request related to a problem?

This relates to #36124, but I think has other benefits.

Describe the solution you'd like

I would like pandas to infer an array of Enums as categorical data. Today, IntEnums are turned into Ints, which is not ideal behavior.

API breaking implications

This is a change to the way part of the current API behaves, but I believe it provides a more intuitive processing of Enum data.

Describe alternatives you've considered

Additional context

# Your code here, if applicable
@dzimmanck dzimmanck added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 2, 2020
@dsaxton dsaxton changed the title ENH: ENH: Infer Enums as categorical Oct 3, 2020
@dsaxton dsaxton added Categorical Categorical Data Type and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 3, 2020
@TomAugspurger
Copy link
Contributor

This feels relatively expensive compared to the other dtypes we infer. We would need to track all the distinct types in data, extract the enum types, ensure that they're unique, and then extract the categories.

I'd prefer to make it easier to convert an Enum to a CategoricalDtype. Perhaps a CategoricalDtype.from_enum constructor.

@dzimmanck
Copy link
Author

@TomAugspurger. I agree. I still however don't think IntEnums should be inferred as standard integers, but maybe that should be a different thread for discussion.

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

No branches or pull requests

3 participants