I have a Pandas data frame and one of the columns, have dates in string format of YYYY-MM-DD
.
For e.g. : '2013-10-28'
At the moment the dtype
of the column is object
.
How do I convert the column values to Pandas date format?
Use astype
In [31]: df
Out[31]:
a time
0 1 2013-01-01
1 2 2013-01-02
2 3 2013-01-03
In [32]: df['time'] = df['time'].astype('datetime64[ns]')
In [33]: df
Out[33]:
a time
0 1 2013-01-01 00:00:00
1 2 2013-01-02 00:00:00
2 3 2013-01-03 00:00:00