qis.split_df_by_groups

qis.split_df_by_groups(df, group_data, total_column=None, group_order=None)[source]

split a panel’s columns into one frame per group.

The frame is time by asset and group_data maps asset to group, so this returns one time-by-asset frame per group. Groups with no columns present in df are omitted rather than returned empty.

Parameters:
  • df (DataFrame) – panel indexed by date with one column per asset

  • group_data (Series) – group label per asset, indexed by asset

  • total_column (str | None) – name of an extra group holding every classified column. Must differ from the labels in group_data. None adds none

  • group_order (List[str]) – order of the groups. None orders by first appearance

Returns:

group label to the sub-panel of df, each a copy rather than a view

Raises:

ValueError – if total_column matches a label in group_data

Return type:

Dict[str, DataFrame]