polars.internals.series.datetime.DateTimeNameSpace.weekday#

DateTimeNameSpace.weekday() Series[source]#

Extract the week day from the underlying date representation.

Applies to Date and Datetime columns.

Returns the weekday number where monday = 0 and sunday = 6

Returns:
Weekday as UInt32

Examples

>>> from datetime import datetime
>>> start = datetime(2001, 1, 1)
>>> stop = datetime(2001, 1, 7)
>>> date = pl.date_range(start, stop, interval="1d")
>>> date
shape: (7,)
Series: '' [datetime[μs]]
[
        2001-01-01 00:00:00
        2001-01-02 00:00:00
        2001-01-03 00:00:00
        2001-01-04 00:00:00
        2001-01-05 00:00:00
        2001-01-06 00:00:00
        2001-01-07 00:00:00
]
>>> date.dt.weekday()
shape: (7,)
Series: '' [u32]
[
        0
        1
        2
        3
        4
        5
        6
]