assuming that you are talking about pandas dataset, you can use pandas to_datetime() method:
In [66]: dates = ['1 / 22 / 2016 15:03', 'Jul 22 2016 12:32PM', 'Jul 22 2016 5:40PM',
....: 'Jul 22 2016 8:31PM', 'Jul 23 2016 2:01PM', 'Jul 23 2016 7:24PM',
....: 'Jul 24 2016 4:30PM', 'Aug 1 2016 4:00PM', 'Aug 1 2016 7:49PM']
In [67]: df = pd.DataFrame({'d':dates})
In [68]: df.dtypes
Out[68]:
d object
dtype: object
d object - means that the d column is of a string (object) dtype
In [69]: df
Out[69]:
d
0 1 / 22 / 2016 15:03
1 Jul 22 2016 12:32PM
2 Jul 22 2016 5:40PM
3 Jul 22 2016 8:31PM
4 Jul 23 2016 2:01PM
5 Jul 23 2016 7:24PM
6 Jul 24 2016 4:30PM
7 Aug 1 2016 4:00PM
8 Aug 1 2016 7:49PM
let's convert it to datetime dtype:
In [70]: df.d = pd.to_datetime(df.d)
In [71]: df
Out[71]:
d
0 2016-01-22 15:03:00
1 2016-07-22 12:32:00
2 2016-07-22 17:40:00
3 2016-07-22 20:31:00
4 2016-07-23 14:01:00
5 2016-07-23 19:24:00
6 2016-07-24 16:30:00
7 2016-08-01 16:00:00
8 2016-08-01 19:49:00
check dtype again:
In [72]: df.dtypes
Out[72]:
d datetime64[ns]
dtype: object
parse()the way it is instead of writing a function that calls the function only?