Reputation: 99
I have a table with time-stamped data, like this:
How do I convert the entire TimeStamp column from UTC to local time with the pytz module? Input is an IANA formatted timezone, like eg. "Europe/London". The table is stored in a pandas dataframe.
Upvotes: 0
Views: 1733
Reputation: 1607
Do you really need the pytz module ? You can use tz
info within the pandas.
for eg. something like this can be done:
df['timestamp'] = df['timestamp'].dt.tz_localize('UTC').dt.tz_convert('Europe/London')
You may want to check more detail here: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.tz_convert.html
Upvotes: 0