How to change date format?

Hi!
In the data set that I’m using the dates have been uploaded as an object with the following structure 2015-01-01 04:00:00+01:00.
When I try to covert the to datetime 64 using:
energy_df[‘time’]=pd.to_datetime(energy_df.time)
energy_df.set_index(energy_df.time,inplace=True)
I get the following error:
ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True
But when I add the parameter utc=True the value for 2015-01-01 00:00:00+01:00 turns into 2014-12-31 23:00:00+00:00.

Can anybody help me solve this problem so that my dataset doesn’t get distorted.

Thanks

Hey you are getting correct results it’s because of the timezone, in your raw df you can see the timezone is +1:00:00 which means it’s one hour in advance from the Universal time zone so when you are converting to Date time all the values are getting converted into one single time zone Ie. the Universal time zone.

Thank you so much.
So the best option would be to directly drop the first row of the data and work just from the first of January 2015.

Thanks!!

Well, if all the data are in a similar timezone, you could add/subtract the time according to the timezone after converting the column into DateTime.