Split a DataFrame by the levels of a Categorical column.
df (pd.DataFrame) – Input DataFrame.
f (str) – Name of a column that has pd.Categorical dtype.
pd.Categorical
ref (bool, optional) – If True, include the reference (first) level in every split group. Default is False.
True
False
A dictionary keyed by level name.
dict[str, pd.DataFrame]