问题
I have a DataFrame with a timestamp
column which looks like this:
0 2020-01-26 05:00:00-08:00
1 2020-01-26 06:00:00-08:00
[...]
Name: timestamp, dtype: datetime64[ns, pytz.FixedOffset(-480)]
(The timestamp is not the DataFrame's index)
I would like to have that pytz.FixedOffset(-480)
applied (or rather un-applied) to the column, so that it would look like this:
0 2020-01-26 13:00:00
1 2020-01-26 14:00:00
[...]
How can I achieve this without parsing timestamp
manually?
回答1:
Use Series.dt.tz_convert:
df['timestamp'] = df['timestamp'].dt.tz_convert(None)
print (df)
timestamp
0 2020-01-26 13:00:00
1 2020-01-26 14:00:00
来源:https://stackoverflow.com/questions/59919877/pandas-apply-pytz-fixedoffset-to-a-series