polars.date#
- polars.date(year: Expr | str | int, month: Expr | str | int, day: Expr | str | int) Expr [source]#
Create a Polars literal expression of type Date.
- Parameters:
- year
column or literal.
- month
column or literal, ranging from 1-12.
- day
column or literal, ranging from 1-31.
- Returns:
- Expr
Expression of data type
Date
.
Examples
>>> df = pl.DataFrame( ... { ... "month": [1, 2, 3], ... "day": [4, 5, 6], ... } ... )
>>> df.with_columns(pl.date(2024, pl.col("month"), pl.col("day"))) shape: (3, 3) ┌───────┬─────┬────────────┐ │ month ┆ day ┆ date │ │ --- ┆ --- ┆ --- │ │ i64 ┆ i64 ┆ date │ ╞═══════╪═════╪════════════╡ │ 1 ┆ 4 ┆ 2024-01-04 │ │ 2 ┆ 5 ┆ 2024-02-05 │ │ 3 ┆ 6 ┆ 2024-03-06 │ └───────┴─────┴────────────┘