polars.Series.dt.strftime#

Series.dt.strftime(fmt: str) Series[source]#

Format Date/datetime with a formatting rule.

See chrono strftime/strptime.

Returns:
Utf8 Series

Examples

>>> from datetime import datetime
>>> start = datetime(2001, 1, 1)
>>> stop = datetime(2001, 1, 4)
>>> date = pl.date_range(start, stop, interval="1d")
>>> date
shape: (4,)
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
]
>>> date.dt.strftime(fmt="%Y-%m-%d")
shape: (4,)
Series: '' [str]
[
        "2001-01-01"
        "2001-01-02"
        "2001-01-03"
        "2001-01-04"
]