polars.Series.dt.is_leap_year#

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

Determine whether the year of the underlying date representation is a leap year.

Applies to Date and Datetime columns.

Returns:
Series

Series of data type Boolean.

Examples

>>> from datetime import datetime
>>> start = datetime(2000, 1, 1)
>>> stop = datetime(2002, 1, 1)
>>> date = pl.date_range(start, stop, interval="1y", eager=True)
>>> date
shape: (3,)
Series: 'date' [datetime[μs]]
[
        2000-01-01 00:00:00
        2001-01-01 00:00:00
        2002-01-01 00:00:00
]
>>> date.dt.is_leap_year()
shape: (3,)
Series: 'date' [bool]
[
        true
        false
        false
]