Extract the century from underlying representation
Description
Returns the century number in the calendar date.
Usage
<Expr>$dt$century()
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(
century = pl$col("date")$dt$century()
)
#> shape: (5, 2)
#> ┌────────────┬─────────┐
#> │ date ┆ century │
#> │ --- ┆ --- │
#> │ date ┆ i32 │
#> ╞════════════╪═════════╡
#> │ 0999-12-31 ┆ 10 │
#> │ 1897-05-07 ┆ 19 │
#> │ 2000-01-01 ┆ 20 │
#> │ 2001-07-05 ┆ 21 │
#> │ 3002-10-20 ┆ 31 │
#> └────────────┴─────────┘