I have a csv file which looks like this
Study ID,CG_Arrival_Date/Time,Arrival_Date,Arrival_Time
2,1/1/2011 0:03,1/1/2011,0:03:00
3,1/1/2011 0:53,1/1/2011,0:53:00
I wanted to parse arrival date and arrival time, so I worte this on Google Colab.
df = pd.read_csv('/content/SM_AI_Data.csv', index_col=['Study ID'],parse_dates=[['Arrival Date','Arrival Time']])
df.head()
The columns get combined fine, but its data type is still object.
How can I change the code so that it works?
Please see the details above.
I can't reproduce any problem if I specify the columns correctly. I use the indexes here because I'm too lazy to use the names :
This produces
The contents are:
The Date and Time columns can be combined too :
The contents are
It's not possible to tell what the format is from the values. DD/MM/YYYY or MM/DD/YYYY? The correct format can be specified by setting the
dayfirst
parameter toTrue
or False`