Skip to content

current_timestamp

laktory.polars.expressions.current_timestamp ยค

current_timestamp()

Returns the current timestamp at the start of expression evaluation as a Datetime column.

RETURNS DESCRIPTION
Expr

Current timestamp

Examples:

import laktory  # noqa: F401
import polars as pl

df = pl.DataFrame({"x": [0.45, 0.55]})
df = df.with_columns(tstamp=pl.expr.laktory.current_timestamp())
Source code in laktory/polars/expressions/datetime.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def current_timestamp() -> pl.Expr:
    """
    Returns the current timestamp at the start of expression evaluation as a
    Datetime column.

    Returns
    -------
    :
        Current timestamp

    Examples
    --------
    ```py
    import laktory  # noqa: F401
    import polars as pl

    df = pl.DataFrame({"x": [0.45, 0.55]})
    df = df.with_columns(tstamp=pl.expr.laktory.current_timestamp())
    ```
    """

    return pl.lit(utc_datetime())