Skip to content

featurebyte.ViewColumn.dt.day

day: FrozenSeries

Description

Returns the day component of each element. This is also available for Series containing timedelta values, which is a result of taking the difference between two timestamp Series.

Returns

  • FrozenSeries
    Column or Feature containing the day of week component values

Examples

Compute the day component of a timestamp column:

>>> view = catalog.get_view("GROCERYINVOICE")
>>> view["TimestampDay"] = view["Timestamp"].dt.day
>>> view.preview(5).filter(regex="Timestamp")
            Timestamp  TimestampDay
0 2022-01-03 12:28:58             3
1 2022-01-03 16:32:15             3
2 2022-01-07 16:20:04             7
3 2022-01-10 16:18:32            10
4 2022-01-12 17:36:23            12

Compute the interval since the previous event in terms of days:

>>> view = catalog.get_view("GROCERYINVOICE")
>>> view["PreviousTimestamp"] = view["Timestamp"].lag("GroceryCustomerGuid")
>>> view["DaysSincePreviousTimestamp"] = (view["Timestamp"] - view["PreviousTimestamp"]).dt.day
>>> view.preview(5).filter(regex="Timestamp|Customer")
                    GroceryCustomerGuid           Timestamp   PreviousTimestamp  DaysSincePreviousTimestamp
0  007a07da-1525-49be-94d1-fc7251f46a66 2022-01-07 12:02:17                 NaT                         NaN
1  007a07da-1525-49be-94d1-fc7251f46a66 2022-01-11 19:46:41 2022-01-07 12:02:17                    4.322500
2  007a07da-1525-49be-94d1-fc7251f46a66 2022-02-04 13:06:35 2022-01-11 19:46:41                   23.722153
3  007a07da-1525-49be-94d1-fc7251f46a66 2022-03-09 18:51:16 2022-02-04 13:06:35                   33.239363
4  007a07da-1525-49be-94d1-fc7251f46a66 2022-03-15 15:08:34 2022-03-09 18:51:16                    5.845347