acidplyr.split_by_level

acidplyr.split_by_level(df: DataFrame, f: str, ref: bool = False) dict[str, DataFrame]

Split a DataFrame by the levels of a Categorical column.

Parameters:
  • df (pd.DataFrame) – Input DataFrame.

  • f (str) – Name of a column that has pd.Categorical dtype.

  • ref (bool, optional) – If True, include the reference (first) level in every split group. Default is False.

Returns:

A dictionary keyed by level name.

Return type:

dict[str, pd.DataFrame]