polars.internals.series.datetime.DateTimeNameSpace.day#

DateTimeNameSpace.day() Series[source]#

Extract the day from the underlying date representation.

Applies to Date and Datetime columns.

Returns the day of month starting from 1. The return value ranges from 1 to 31. (The last day of month differs by months.)

Returns:
Day part as UInt32

Examples

>>> from datetime import datetime
>>> start = datetime(2001, 1, 1)
>>> stop = datetime(2001, 1, 9)
>>> date = pl.date_range(start, stop, interval="2d")
>>> date
shape: (5,)
Series: '' [datetime[μs]]
[
        2001-01-01 00:00:00
        2001-01-03 00:00:00
        2001-01-05 00:00:00
        2001-01-07 00:00:00
        2001-01-09 00:00:00
]
>>> date.dt.day()
shape: (5,)
Series: '' [u32]
[
        1
        3
        5
        7
        9
]