get_categorical_columns¶
yohou.utils.polars.get_categorical_columns(df, exclude=None)
¶
Get list of categorical column names from a DataFrame.
Categorical columns are those with pl.String, pl.Categorical,
or pl.Enum dtype.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Input DataFrame. |
required |
exclude
|
list[str] | None
|
Column names to exclude from the result. |
None
|
Returns¶
| Type | Description |
|---|---|
list[str]
|
List of categorical column names. |
Examples¶
>>> import polars as pl
>>> from yohou.utils.polars import get_categorical_columns
>>> df = pl.DataFrame({"time": [1, 2, 3], "y": [10.0, 20.0, 30.0], "cat": ["A", "B", "C"]})
>>> get_categorical_columns(df)
['cat']
See Also¶
get_numeric_columns: List numeric column names from a DataFrame.is_categorical_dtype: Check if a dtype is categorical.