categorical#
- skrub.selectors.categorical()[source]#
Select columns that have a Categorical (or polars Enum) data type.
See also
stringSelect string columns.
cardinality_belowSelect columns with low cardinality (low number of unique values).
skrub.ToCategoricalConvert a column to categorical type for explicit category handling.
Examples
>>> from skrub import selectors as s >>> import pandas as pd >>> df = pd.DataFrame( ... dict( ... string=pd.Series(['A', 'B']), ... category=pd.Series(['A', 'B'], dtype="category"), ... ) ... )
>>> df string category 0 A A 1 B B
Select only categorical columns (note: string columns are not selected):
>>> s.select(df, s.categorical()) category 0 A 1 B
Combine with
string()to select all text-like columns:>>> s.select(df, s.categorical() | s.string()) string category 0 A A 1 B B