-
-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Open
@JensHeinrich
Description
Feature Type
-
Adding new functionality to pandas
-
Changing existing functionality in pandas
-
Removing existing functionality in pandas
Problem Description
I wish enum types like StrEnum
would be recognized as Categories by the type guessing functions, e.g. infer_objects
or convert_dtypes
as there is more information there then python[string]
Feature Description
With a frame as follows
from enum import StrEnum import pandas as pd class MyEnum(StrEnum): A="a" B="b" C="c" df=pd.json_normalize([{"k": x } for x in MyEnum if x !=MyEnum.C]).infer_objects()
df.dtypes
should return
k category
dtype: object
instead of
k object
dtype: object
and the category should contain all enum values as they are used for plots.
Alternative Solutions
Manually specify a category for every enum-based column
Additional Context
Maybe the EnumCategories types could even be global like polars so merging on these categories is quicker.