Skip to content

Roll forward to the last day of the month

Description

For datetimes, the time of day is preserved.

Usage

<Expr>$dt$month_end()

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(date = as.Date(c("2000-01-23", "2001-01-12", "2002-01-01")))

df$with_columns(
  month_end = pl$col("date")$dt$month_end()
)
#> shape: (3, 2)
#> ┌────────────┬────────────┐
#> │ date       ┆ month_end  │
#> │ ---        ┆ ---        │
#> │ date       ┆ date       │
#> ╞════════════╪════════════╡
#> │ 2000-01-23 ┆ 2000-01-31 │
#> │ 2001-01-12 ┆ 2001-01-31 │
#> │ 2002-01-01 ┆ 2002-01-31 │
#> └────────────┴────────────┘