pandas.Timestamp.tz_convert¶
- Timestamp.tz_convert(tz)¶
Convert timezone-aware Timestamp to another time zone.
- Parameters
- tzstr, pytz.timezone, dateutil.tz.tzfile or None
Time zone for time which Timestamp will be converted to. None will remove timezone holding UTC time.
- Returns
- convertedTimestamp
- Raises
- TypeError
If Timestamp is tz-naive.
Examples
Create a timestamp object with UTC timezone:
>>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651', tz='UTC') >>> ts Timestamp('2020-03-14 15:32:52.192548651+0000', tz='UTC')
Change to Tokyo timezone:
>>> ts.tz_convert(tz='Asia/Tokyo') Timestamp('2020-03-15 00:32:52.192548651+0900', tz='Asia/Tokyo')
Can also use
astimezone
:>>> ts.astimezone(tz='Asia/Tokyo') Timestamp('2020-03-15 00:32:52.192548651+0900', tz='Asia/Tokyo')
Analogous for
pd.NaT
:>>> pd.NaT.tz_convert(tz='Asia/Tokyo') NaT