Skip to content

featurebyte.to_timedelta

to_timedelta(
series: Series,
unit: Literal["day", "hour", "minute", "second", "millisecond", "microsecond"]
) -> Series

Description

Construct a timedelta Series that can be used to increment a datetime Series.

Parameters

  • series: Series
    Series representing the amount of time unit

  • unit: Literal["day", "hour", "minute", "second", "millisecond", "microsecond"]
    A supported unit in str

Returns

  • Series

Raises

  • ValueError
    if input Series is not of INT type

Examples

Create a new column in the INVOICEITEMS view that represents the number of days since the last invoice.

>>> items_view = catalog.get_view("INVOICEITEMS")
>>> items_view["TIMEDELTA_DAYS_SINCE_LAST_INVOICE"] = fb.to_timedelta(
...   items_view["DAYS_SINCE_LAST_INVOICE"], "day"
... )
Create a new column that is 10 minutes after the event.

>>> items_view = catalog.get_view("INVOICEITEMS")
>>> items_view["10_MINS_AFTER_EVENT"] = items_view["Timestamp"] + pd.Timedelta(10, unit="minute")