qis.set_group_loadings

qis.set_group_loadings(group_data, group_order=None)[source]

one-hot loadings of instruments on groups.

Column g holds 1.0 where group_data equals g and 0.0 elsewhere, so loadings.T @ x aggregates an instrument-indexed vector to group level.

Parameters:
  • group_data (Series) – group label per instrument, indexed by ticker

  • group_order (List[str]) – groups to emit, in column order; defaults to the order of first appearance in group_data. Groups outside the list are dropped, and a group in the list that never occurs yields an all-zero column

Returns:

loadings indexed as group_data, one column per group, values 1.0 or 0.0

Raises:

ValueError – if group_data is not a pd.Series

Return type:

DataFrame