How to change date format?

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:
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.


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.


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.