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
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
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)