Skip to content

Extract the millennium from underlying representation

Source code

Description

Returns the millennium number in the calendar date.

Usage

<Expr>$dt$millennium()

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(
  date = as.Date(
    c("999-12-31", "1897-05-07", "2000-01-01", "2001-07-05", "3002-10-20")
  )
)
df$with_columns(
  millennium = pl$col("date")$dt$millennium()
)
#> shape: (5, 2)
#> ┌────────────┬────────────┐
#> │ date       ┆ millennium │
#> │ ---        ┆ ---        │
#> │ date       ┆ i32        │
#> ╞════════════╪════════════╡
#> │ 0999-12-31 ┆ 1          │
#> │ 1897-05-07 ┆ 2          │
#> │ 2000-01-01 ┆ 2          │
#> │ 2001-07-05 ┆ 3          │
#> │ 3002-10-20 ┆ 4          │
#> └────────────┴────────────┘