Skip to content

featurebyte.EventViewColumn.lag

lag(
entity_columns: Union[str, List[str]],
offset: int=1
) -> LagColumnTypeT

Description

Lag is a transform that enables the retrieval of the preceding value associated with a particular entity in a view.

This makes it feasible to compute essential features, such as those that depend on inter-event time and the proximity to the previous point.

Parameters

  • entity_columns: Union[str, List[str]]
    Entity columns used when retrieving the lag value.

  • offset: int
    default: 1
    The number of rows backward from which to retrieve a value.

Returns

  • LagColumnTypeT

Raises

  • ValueError
    If a lag operation has already been applied to the column.

Examples

Create a new column that indicates the prior event timestamp for a Customer.

>>> event_view = catalog.get_view("GROCERYINVOICE")
>>> lagged_column = event_view["Timestamp"].lag("GroceryCustomerGuid")
Create a new column that indicates the 2nd prior event timestamp for a Customer.

>>> lagged_2_column = event_view["Timestamp"].lag("GroceryCustomerGuid", offset=2)