Skip to content

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

Source code

Description

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

Usage

<Expr>$dt$is_leap_year()

Value

An Expr of datatype Bool

Examples

library("polars")

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

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