Hello,

I have a file containing mixed data types: strings, floats, datetime
output(i.e. strings), and ints. Something like:

#ID, name, date, value
1,sample,2008-07-10 12:34:20,344.56

And so forth. It seems using recarrays is efficient and a prefered habit to
get into wrg to numpy, so I am trying the following:

dtype=[('ID','int'),('name','|S10'),('date','????'),('value','float')]

DATA = np.loadtxt(infile,dtype=dtype)

This works if I set 'date' type to 'S20', but wouldn't it be more
appropriate to use object? Also, what is the next step to then use the
values as datetime objects?

Do I have to take the data out of the array, convert to datetime, then put
back in the array?

dates = DATA['date']
dates = [dt.datetime.strptime(d,'%Y-%m-%d %H:%M:%S') for d in dates]
DATA['dates'] = np.array(dates)

????

Thanks!
-- 
View this message in context: 
http://www.nabble.com/recarray-and-datetime-objects-tp24568340p24568340.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to