I have numpy array of strings (p.s. why is string represented as object?!)
t = array(['21/02/2014 08:40:00 AM', '11/02/2014 10:50:00 PM',
'07/04/2014 05:50:00 PM', '17/02/2014 10:20:00 PM',
'07/03/2014 06:10:00 AM', '02/03/2014 12:25:00 PM',
'05/02/2014 03:20:00 AM', '31/01/2014 12:30:00 AM',
'28/02/2014 01:25:00 PM'], dtype=object)
I would like to convert it to numpy.datetime64 with day resolution, however the only solution I found is:
t = [datetime.strptime(tt,"%d/%m/%Y %H:%M:%S %p") for tt in t]
t = np.array(t,dtype='datetime64[us]').astype('datetime64[D]')
Can it get uglier than that? Why do I need to go through native Python list?
There must be another way...
By the way, I cannot find a way