Skip to content

daft.functions.date_from_unix_date#

date_from_unix_date #

date_from_unix_date(expr: Expression) -> Expression

Converts days since Unix epoch (1970-01-01) to a date.

Parameters:

Name Type Description Default
expr Expression

An integer expression representing days since epoch.

required

Returns:

Name Type Description
Expression Expression

a Date expression.

Examples:

1
2
3
4
5
>>> import daft
>>> from daft.functions import date_from_unix_date
>>> df = daft.from_pydict({"days": [0, 18628]})
>>> df = df.with_column("d", date_from_unix_date(df["days"]))
>>> df.schema()["d"].dtype == daft.DataType.date()
True
Source code in daft/functions/datetime.py
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
def date_from_unix_date(expr: Expression) -> Expression:
    """Converts days since Unix epoch (1970-01-01) to a date.

    Args:
        expr: An integer expression representing days since epoch.

    Returns:
        Expression: a Date expression.

    Examples:
        >>> import daft
        >>> from daft.functions import date_from_unix_date
        >>> df = daft.from_pydict({"days": [0, 18628]})
        >>> df = df.with_column("d", date_from_unix_date(df["days"]))
        >>> df.schema()["d"].dtype == daft.DataType.date()
        True
    """
    return Expression._call_builtin_scalar_fn("date_from_unix_date", expr)