Reputation: 555
I have one dataframe like the following:
A
2014-06-02 09:00:00-04:00 ...
2014-06-02 10:00:00-04:00 ...
2014-06-02 11:00:00-04:00 ...
2014-06-02 12:00:00-04:00 ...
I need the index to be a datetime to make some operations so I am trying:
df.index = pd.to_datetime(df.index)
But I am getting the following error
ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True
Please note that the index is localized (-04:00)
pandas 0.24.2
Upvotes: 0
Views: 79
Reputation: 2015
You may follow the suggestion from the error:
df.index = pd.to_datetime(df.index, utc=True)
You may also convert the time to a -04:00
timezone with tz_convert('US/Eastern')
Upvotes: 2