polars.datetime#

polars.datetime(
year: int | IntoExpr,
month: int | IntoExpr,
day: int | IntoExpr,
hour: int | IntoExpr | None = None,
minute: int | IntoExpr | None = None,
second: int | IntoExpr | None = None,
microsecond: int | IntoExpr | None = None,
*,
time_unit: TimeUnit = 'us',
time_zone: str | None = None,
use_earliest: bool | None = None,
) Expr[source]#

Create a Polars literal expression of type Datetime.

Parameters:
year

Column or literal.

month

Column or literal, ranging from 1-12.

day

Column or literal, ranging from 1-31.

hour

Column or literal, ranging from 0-23.

minute

Column or literal, ranging from 0-59.

second

Column or literal, ranging from 0-59.

microsecond

Column or literal, ranging from 0-999999.

time_unit{‘us’, ‘ms’, ‘ns’}

Time unit of the resulting expression.

time_zone

Time zone of the resulting expression.

use_earliest

Determine how to deal with ambiguous datetimes:

  • None (default): raise

  • True: use the earliest datetime

  • False: use the latest datetime

Returns:
Expr

Expression of data type Datetime.