0

I'm using Python to convert a column in my dataframe to a datetime format (which is initially loaded from a CSV file and in object format).

After loading...

data.info()

...results in Date 2142 non-null object. Using...

data['Date1'] = pd.to_datetime(df['Date'],format='%d/%m/%y')

...does indeed produce a datetime column, but the date gets messed up. The first two rows, for instance, are as follows:

Date     Date1
26/08/16 2017-08-18
27/08/16 2017-08-19

As you can see, both columns have nothing in common. I get the same result when I leave out the format element. How can I get the correct date after using to_datetime?

Thanks

Ancora Imparo
  • 331
  • 1
  • 6
  • 20
Berbatov
  • 999
  • 1
  • 10
  • 18

0 Answers0