Skip to content

Extract the number of days in the month from the underlying Date representation.

Source code

Description

Extract the number of days in the month from the underlying Date representation.

Usage

<Expr>$dt$days_in_month()

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(date = as.Date(c("2020-01-01", "2020-02-01", "2020-03-01")))

df$with_columns(
  days_in_month = pl$col("date")$dt$days_in_month()
)
#> shape: (3, 2)
#> ┌────────────┬───────────────┐
#> │ date       ┆ days_in_month │
#> │ ---        ┆ ---           │
#> │ date       ┆ i8            │
#> ╞════════════╪═══════════════╡
#> │ 2020-01-01 ┆ 31            │
#> │ 2020-02-01 ┆ 29            │
#> │ 2020-03-01 ┆ 31            │
#> └────────────┴───────────────┘