Aggregate type: aggregate#
- class lumen.transforms.base.Aggregate(*, by, columns, kwargs, method, with_index, controls, name)#
Aggregate one or more columns or indexes, see pandas.DataFrame.groupby.
by must be provided.
df.groupby(<by>)[<columns>].<method>()[.reset_index()]
Parameters#
type: Any
default: None
Possible values: ``
Columns or indexes to group by.
type: Any
default: None
Possible values: ``
Columns to aggregate.
type: dict
default: {}
Keyword arguments to the aggregation method.
type: str
default: 'mean'
Name of the pandas aggregation method, e.g. max, min, count.
type: bool
default: True
Whether to make the groupby columns indexes.
Methods#
- Aggregate.apply(table: DataFrame) DataFrame #
Given a table transform it in some way and return it.
- Parameters:
table (DataFrame) – The queried table as a DataFrame.
- Returns:
A DataFrame containing the transformed data.
- Return type:
DataFrame
- Aggregate.to_spec(context: Dict[str, Any] | None = None) Dict[str, Any] #
Exports the full specification to reconstruct this component.
- Return type:
Resolved and instantiated Component object