pandas.Series.dt.tz_convert#

Series.dt.tz_convert(tz)[source]#

Convert tz-aware datetimes from one time zone to another.

This method converts datetime values from their current timezone to a different timezone. The underlying UTC time remains the same, only the local time representation changes to reflect the target timezone.

Parameters:
tzstr, zoneinfo.ZoneInfo, pytz.timezone, dateutil.tz.tzfile, datetime.tzinfo or None

Time zone to convert the timestamps to. A tz of None will convert to UTC and remove the timezone information.

Returns:
Series or DatetimeArray

The values converted to the target tz.

Raises:
TypeError

If the values are tz-naive.

See also

DatetimeIndex.tz_convert

Convert a tz-aware DatetimeIndex from one time zone to another.

Series.dt.tz

A timezone that has a variable offset from UTC.

Series.dt.tz_localize

Localize tz-naive Series datetimes to a given time zone, or remove timezone from tz-aware Series datetimes.

Examples

>>> ser = pd.Series(
...     pd.date_range(
...         start="2014-08-01 09:00", freq="h", periods=3, tz="Europe/Berlin"
...     )
... )
>>> ser
0   2014-08-01 09:00:00+02:00
1   2014-08-01 10:00:00+02:00
2   2014-08-01 11:00:00+02:00
dtype: datetime64[us, Europe/Berlin]
>>> ser.dt.tz_convert("US/Central")
0   2014-08-01 02:00:00-05:00
1   2014-08-01 03:00:00-05:00
2   2014-08-01 04:00:00-05:00
dtype: datetime64[us, US/Central]

With tz=None, we can remove the timezone after converting to UTC:

>>> ser.dt.tz_convert(None)
0   2014-08-01 07:00:00
1   2014-08-01 08:00:00
2   2014-08-01 09:00:00
dtype: datetime64[us]