daft.Expression.dt.time

daft.Expression.dt.time#

Expression.dt.time() Expression[source]#

Retrieves the time for a datetime column

Example

>>> import daft, datetime
>>> df = daft.from_pydict(
...     {
...         "x": [
...             datetime.datetime(2021, 1, 1, 0, 1, 1),
...             datetime.datetime(2021, 1, 1, 12, 1, 59),
...             datetime.datetime(2021, 1, 1, 23, 59, 59),
...         ],
...     }
... )
>>> df = df.with_column("time", df["x"].dt.time())
>>> df.show()
╭───────────────────────────────┬────────────────────╮
│ x                             ┆ time               │
│ ---                           ┆ ---                │
│ Timestamp(Microseconds, None) ┆ Time(Microseconds) │
╞═══════════════════════════════╪════════════════════╡
│ 2021-01-01 00:01:01           ┆ 00:01:01           │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ 2021-01-01 12:01:59           ┆ 12:01:59           │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ 2021-01-01 23:59:59           ┆ 23:59:59           │
╰───────────────────────────────┴────────────────────╯

(Showing first 3 of 3 rows)
Returns:

a Time expression

Return type:

Expression