polars.Series.dt.combine#

Series.dt.combine(tm: time | Series, tu: TimeUnit = 'us') Expr[source]#

Create a naive Datetime from an existing Date/Datetime expression and a Time.

If the underlying expression is a Datetime then its time component is replaced, and if it is a Date then a new Datetime is created by combining the two values.

Parameters:
tm

A python time literal or Series of the same length as this Series.

tu{‘ns’, ‘us’, ‘ms’}

Time unit.

Examples

>>> from datetime import datetime, time
>>> s = pl.Series(
...     "dtm",
...     [datetime(2022, 12, 31, 10, 30, 45), datetime(2023, 7, 5, 23, 59, 59)],
... )
>>> s.dt.combine(time(1, 2, 3, 456000))
shape: (2,)
Series: 'dtm' [datetime[μs]]
[
    2022-12-31 01:02:03.456
    2023-07-05 01:02:03.456
]