ColumnAggregator

Aggregate columns.

class numom2b_preprocessing.aggregate_columns.ColumnAggregator(data_frame)[source]

Mutate a data frame according to configuration parameters. Drop the modified columns.

aggregate(operations_list)[source]

Mutate a data frame according to configuration parameters.

Parameters:operations_list – List of dictionaries with ‘operator’ and ‘columns’ keys.

Examples:

>>> data_frame = pd.DataFrame({"ID": [0, 1, 2], "a": [3.3, 4.5, 1.2], "b": [3, 2, 4})
>>> ca = ColumnAggregator()
>>> ca.aggregate(
...     [
...         {
...             "operator": "mean", 
...             "columns": ["a, "b"],
...             "rename": "mean_a_b",
...         },
...     ],
... )