Skip to content

featurebyte.ChangeViewColumn.lag

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

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

  • ChangeViewColumn

Raises

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

Examples

Get a ChangeView to track changes in Customer's State.

>>> scd_table = catalog.get_table("GROCERYCUSTOMER")
>>> change_view = scd_table.get_change_view(track_changes_column="State")
Create a new column that indicates the prior past_State for a Customer

>>> lagged_column = change_view["past_State"].lag("GroceryCustomerGuid")