Timestamp.astimezone()
from the pandas software library is used to convert the timezone-aware Timestamp
into another time zone.
Timestamp.astimezone(tz)
import pandas as pdts = pd.Timestamp('2021-02-10 01:15:52.192348551+0800', tz='UTC')print(ts)ts.astimezone('Europe/Berlin')print(ts)
import pandas as pdts= pd.Timestamp(year = 2022, month = 1, day = 31,hour = 12, minute = 49, tz = 'Asia/Tokyo')# Convert to Tokyo time zone:ts.astimezone(tz='US/Central')print(ts)
Line 2: We create Timestamp()
instance, with year
, month
, day
, hour
, minute
and time zone UTC
as an additional argument.
Line 5: We change the time zone to US/Central
.