polars.Series.dt.with_time_zone#

Series.dt.with_time_zone(tz: str | None) Series[source]#

Set time zone a Series of type Datetime.

Parameters:
tz

Time zone for the Datetime Series.

Examples

>>> from datetime import datetime
>>> start = datetime(2020, 3, 1)
>>> stop = datetime(2020, 5, 1)
>>> date = pl.date_range(start, stop, "1mo")
>>> date
shape: (3,)
Series: '' [datetime[μs]]
[
        2020-03-01 00:00:00
        2020-04-01 00:00:00
        2020-05-01 00:00:00
]
>>> date = date.dt.with_time_zone(tz="Europe/London").alias("London")
>>> date
shape: (3,)
Series: 'London' [datetime[μs, Europe/London]]
[
    2020-03-01 00:00:00 GMT
    2020-04-01 01:00:00 BST
    2020-05-01 01:00:00 BST
]