polars.Series.dt.month_end#

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

Roll forward to the last day of the month.

Returns:
Series

Series of data type Date or Datetime.

Notes

If you’re coming from pandas, you can think of this as a vectorised version of pandas.tseries.offsets.MonthEnd().rollforward(datetime).

Examples

>>> from datetime import datetime
>>> s = pl.datetime_range(
...     datetime(2000, 1, 2, 2), datetime(2000, 4, 2, 2), "1mo", eager=True
... ).alias("datetime")
>>> s.dt.month_end()
shape: (4,)
Series: 'datetime' [datetime[μs]]
[
        2000-01-31 02:00:00
        2000-02-29 02:00:00
        2000-03-31 02:00:00
        2000-04-30 02:00:00
]