featurebyte.view.GroupBy.forward_aggregate¶
forward_aggregate(
value_column: str,
method: str,
window: Optional[str]=None,
target_name: Optional[str]=None,
fill_value: Union[StrictInt, StrictFloat, StrictStr, bool, NoneType]=None,
skip_fill_na: Optional[bool]=None,
offset: Optional[str]=None
) -> 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: Optional[str]
Optional window to apply to the point in time column in the target request. - target_name: Optional[str]
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: Optional[bool]
Whether to skip filling NaN values, filling nan operation is skipped by default as it is expensive during feature serving - offset: Optional[str]
Offset duration to apply to the window, such as '1d'. If specified, the windows will be shifted forward by the offset duration
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'
... )