[Numpy-discussion] Merging structured arrays with mixed dtypes including '|O4'

Alex zdoor@xs4all...
Mon Jan 28 09:06:59 CST 2013


Let's say I have two structured arrays with dtypes as per below

>>> getdat.dtype
dtype([('Tstamp', '|O4'), ('Vf', '<f4'), ('Vq', '<f4'), ('Sf', '<f4'), 
('Sq', '<f4'), ('Bt', '<f4'), ('SPL', '<f4')])

>>> out.dtype
dtype([('Viscosity_cSt', '<f4'), ('Density_kgm3', '<f4'), ('GVF', '<f4')])

Then merging this per the below gives an error. Why?

>>> rfn.merge_arrays((getdat, out), flatten = True, usemask = False, 
asrecarray=False)

Traceback (most recent call last):
  File "<pyshell#43>", line 1, in <module>
    rfn.merge_arrays((getdat, out), flatten = True, usemask = False, 
asrecarray=False)
  File "C:\Python27\lib\site-packages\numpy\lib\recfunctions.py", line 458, in 
merge_arrays
    dtype=newdtype, count=maxlength)
ValueError: cannot create object arrays from iterator

The issue seems to be object field 'Tstamp' which contains python datetime 
objects. I can merge structured arrays with numeric formats.

Any help much appreciated.
Alex van der Spek



More information about the NumPy-Discussion mailing list