captest.capdata.CapData.agg_group

CapData.agg_group(group_id, agg_func, verbose=True, rename_map=None, inplace=True, cutoff=10, columns=None)

Aggregate columns in a group.

Parameters:
  • group_id (str) – Key from column_groups attribute.

  • agg_func (str or callable) – Aggregation function to apply.

  • verbose (bool, default True) – Set to True to print the columns that have been aggregated, the aggregation function used, and the new column name.

  • cutoff (int, default 10) – Maximum number of columns to list individually when verbose=True. When the group contains more columns than this value, the first three and last three column names are printed with an ellipsis in between. Increase this value to see more columns listed individually.

  • columns (pd.DataFrame or None, default None) – Pre-fetched DataFrame of columns to aggregate. When provided the lookup via self._get_group is skipped. Intended for internal use by agg_sensors to avoid a redundant lookup.

Notes

When agg_func is "sum" the aggregation is performed with min_count=1 so that a row in which every column is NaN returns NaN rather than 0.0 (the pandas default). Rows with at least one value still skip NaN and sum the remaining values.