polars.Series.dt.hours#

Series.dt.hours() Series[source]#

Extract the hours from a Duration type.

Returns:
Series

Series of data type Int64.

Examples

>>> from datetime import datetime
>>> date = pl.date_range(
...     datetime(2020, 1, 1), datetime(2020, 1, 4), "1d", eager=True
... )
>>> date
shape: (4,)
Series: 'date' [datetime[μs]]
[
        2020-01-01 00:00:00
        2020-01-02 00:00:00
        2020-01-03 00:00:00
        2020-01-04 00:00:00
]
>>> date.diff().dt.hours()
shape: (4,)
Series: 'date' [i64]
[
        null
        24
        24
        24
]