Skip to content

daft.functions.timestamp_seconds#

timestamp_seconds #

timestamp_seconds(expr: Expression) -> Expression

Creates a timestamp from seconds since Unix epoch.

Parameters:

Name Type Description Default
expr Expression

A numeric expression representing seconds since epoch.

required

Returns:

Name Type Description
Expression Expression

a Timestamp[us] expression.

Examples:

1
2
3
4
5
>>> import daft
>>> from daft.functions import timestamp_seconds
>>> df = daft.from_pydict({"s": [0, 1609459200]})
>>> df = df.with_column("ts", timestamp_seconds(df["s"]))
>>> df.schema()["ts"].dtype == daft.DataType.timestamp("us")
True
Source code in daft/functions/datetime.py
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
def timestamp_seconds(expr: Expression) -> Expression:
    """Creates a timestamp from seconds since Unix epoch.

    Args:
        expr: A numeric expression representing seconds since epoch.

    Returns:
        Expression: a Timestamp[us] expression.

    Examples:
        >>> import daft
        >>> from daft.functions import timestamp_seconds
        >>> df = daft.from_pydict({"s": [0, 1609459200]})
        >>> df = df.with_column("ts", timestamp_seconds(df["s"]))
        >>> df.schema()["ts"].dtype == daft.DataType.timestamp("us")
        True
    """
    return Expression._call_builtin_scalar_fn("timestamp_seconds", expr)