problem setting O type for datetime field in record arrays
I can create a record array with datetime types using fromrecords if I don't specify a dtype and let numpy determine the dtype. But when I try and set the dtype at record array creation time, I get the error below In [17]: import numpy In [18]: import datetime In [19]: dt = datetime.datetime In [20]: dt1 = dt.now() In [21]: dt2 = dt.now() In [22]: numpy.core.rec.fromrecords([[dt1, 0.5], [dt2, 1.0]], names='date,height') Out[22]: recarray([(datetime.datetime(2007, 6, 14, 13, 59, 20, 753356), 0.5), (datetime.datetime(2007, 6, 14, 13, 59, 22, 946850), 1.0)], dtype=[('date', '|O4'), ('height', '<f8')]) In [23]: numpy.core.rec.fromrecords([[dt1, 0.5], [dt2, 1.0]], dtype=[('date', '|O4'), ('height', '<f8')]) ------------------------------------------------------------ Traceback (most recent call last): File "<ipython console>", line 1, in ? File "/home/titan/johnh/dev/lib/python2.4/site-packages/numpy/core/records.py", line 399, in fromrecords retval = sb.array(recList, dtype = descr) ValueError: tried to set void-array with object members using buffer. In [24]: numpy.__version__ Out[24]: '1.0.4.dev3868'
participants (1)
-
John Hunter