I am trying to convert three of my columns (created at, updated_at,recorded_at) into datetime format using python panda. I am using a CSV file and it is given below
id name created_at updated_at deliverable_type recorded_at pax
10001 jack 35:21.0 40:05.0 Table 35:20.9 1
10002 mark 42:29.5 42:30.5 Section 9/13/16 11:42 \N
10003 sam 57:29.7 57:30.5 Section 9/13/16 11:57 \N
10004 alex 58:03.7 58:04.7 Section 9/13/16 11:58 \N
10005 jacki 58:43.4 58:46.7 Section 9/13/16 12:00 \N
10006 sunil 08:53.2 08:54.8 Section 9/13/16 12:08 \N
10007 max 26:46.0 26:49.1 Section 9/13/16 12:28 \N
10008 alice 27:24.1 27:26.1 Section 9/13/16 12:27 \N
10009 markus 28:01.0 29:42.7 Table 28:01.0 2
10010 dan 48:40.0 48:45.6 Section 9/13/16 12:50 \N
10011 jill 56:15.7 56:16.5 Section 9/13/16 12:56 \N
10012 amanda 41:54.2 41:55.9 Section 9/13/16 13:41 \N
I have tired the to_datetime on one of my columns but it does not seem to work.
import pandas as pd
thedate = ['created_at','updated_at','recorded_at']
df = pd.read_csv('TheCV.csv',parse_dates=thedate)
theDF = pd.DataFrame(df)
date_object = pd.to_datetime(theDF['created_at'],format='%H:%M:%S %p',errors='ignore')
print(date_object.head())
date_object.to_csv('theccsv.csv')
Can someone tell how can i get the 3 columns converted to a datetime formate
This is the result i get after i print it