Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pandas parse_dates does not seem to work

I have this sample of a data_frame:

name,time_0
name,22/04/2014 00:44
OTROGUAPOSUELTO,22/04/2014 13:20

I want to parse time_0, but doing:

df = pd.read_csv(data_string,header=0,parse_dates='time_0', dayfirst=True)

brings me back an 'object' dtype for time_0, instead of a date_time object.

Anyone?

Thanks a lot for your help

like image 867
Barnabe Avatar asked Oct 16 '25 13:10

Barnabe


1 Answers

Try this:

In [2]: df = pd.read_csv(data_string, header=0, parse_dates=[1], dayfirst=True)

In [3]: df.dtypes
Out[3]:
name              object
time_0    datetime64[ns]
dtype: object
like image 70
Amit Verma Avatar answered Oct 19 '25 10:10

Amit Verma