qis.get_group_dict

qis.get_group_dict(group_data, index_data=None, group_order=None, total_column=None)[source]

map each group label to the tickers belonging to it.

group_data is the house convention for asset-class metadata: a Series indexed by ticker whose values are the group labels. This inverts it into group to tickers, which is the shape the grouped reporting layer consumes.

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

  • index_data (Index | List[str] | ndarray) – restrict the result to these tickers, and order them accordingly. None uses every ticker in group_data

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

  • total_column (str | None) – name of an extra group holding every ticker, for a total row alongside the groups. Must differ from every label in group_data, even when index_data excludes that group’s tickers. None adds none

Returns:

group label to the tickers in it, in group_order

Raises:
  • ValueError – if group_data is not a Series, if it or index_data contains nulls, or if total_column matches an observed group label

  • TypeError – if index_data is not an Index, list or array

Return type:

Dict[str, List[str]]