featurebyte.view.GroupBy.forward_aggregate¶
forward_aggregate(
value_column: str,
method: str,
window: Union[str, NoneType]=None,
target_name: Union[str, NoneType]=None,
fill_value: Union[StrictInt, StrictFloat, StrictStr, bool, NoneType]=None,
skip_fill_na: bool=False
) -> TargetDescription¶
The forward_aggregate method of a GroupBy class instance returns a Forward Aggregated Target object. This object aggregates data from the column specified by the value_column parameter using the aggregation method provided by the method parameter, without taking into account the order or sequence of the data. The primary entity of the Target is determined by the grouping key of the GroupBy instance.
Parameters¶
- value_column: str
Column to be aggregated - method: str
Aggregation method. - window: Union[str, NoneType]
Optional window to apply to the point in time column in the target request. - target_name: Union[str, NoneType]
Output target name - fill_value: Union[StrictInt, StrictFloat, StrictStr, bool, NoneType]
Value to fill if the value in the column is empty - skip_fill_na: bool
default: False
Whether to skip filling NaN values
Returns¶
- Target
Examples¶
>>> items_view = catalog.get_view("INVOICEITEMS")
>>> # Group items by the column GroceryInvoiceGuid that references the customer entity
>>> items_by_invoice = items_view.groupby("GroceryInvoiceGuid")
>>> # Get the number of items in each invoice
>>> invoice_item_count = items_by_invoice.forward_aggregate(
... "TotalCost",
... method=fb.AggFunc.SUM,
... target_name="TargetCustomerInventory_28d",
... window='28d'
... )