Skip to content

Commit

Permalink
Add Python side
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Aug 1, 2023
1 parent 1c0ad40 commit 25b2f1b
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions py-polars/polars/functions/as_datatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,44 @@
from typing import Literal

from polars import Expr, Series
from polars.type_aliases import IntoExpr, SchemaDict
from polars.type_aliases import IntoExpr, SchemaDict, TimeUnit


def datetime_(
year: Expr | str | int,
month: Expr | str | int,
day: Expr | str | int,
hour: Expr | str | int | None = None,
minute: Expr | str | int | None = None,
second: Expr | str | int | None = None,
microsecond: Expr | str | int | None = None,
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,
) -> Expr:
"""
Create a Polars literal expression of type Datetime.
Parameters
----------
year
column or literal.
Column or literal.
month
column or literal, ranging from 1-12.
Column or literal, ranging from 1-12.
day
column or literal, ranging from 1-31.
Column or literal, ranging from 1-31.
hour
column or literal, ranging from 0-23.
Column or literal, ranging from 0-23.
minute
column or literal, ranging from 0-59.
Column or literal, ranging from 0-59.
second
column or literal, ranging from 0-59.
Column or literal, ranging from 0-59.
microsecond
column or literal, ranging from 0-999999.
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.
Returns
-------
Expand Down Expand Up @@ -80,6 +87,8 @@ def datetime_(
minute,
second,
microsecond,
time_unit,
time_zone,
)
)

Expand Down

0 comments on commit 25b2f1b

Please sign in to comment.