python: numpy: - Verkettung der Namen-arrays

Betrachten Sie das folgende einfache Beispiel:

x = numpy.array([(1,2),(3,4)],dtype=[('a','<f4'),('b','<f4')])
y = numpy.array([(1,2),(3,4)],dtype=[('c','<f4'),('d','<f4')])
numpy.hstack((x,y))

Wird die folgende Fehlermeldung erhalten:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python33\lib\site-packages\numpy\core\shape_base.py", line 226, in vstack
    return _nx.concatenate(list(map(atleast_2d,tup)),0)
TypeError: invalid type promotion

Wenn das array hatte keine Titel, es funktioniert

x = numpy.array([(1,2),(3,4)],dtype='<f4')
y = numpy.array([(1,2),(3,4)],dtype='<f4')
numpy.hstack((x,y))

Wenn ich Entferne die Namen aus x-und y-es funktioniert auch.

Frage: wie verketten, vstack oder hstack der Titel numpy-array ?
Hinweis: numpy.lib.recfunctions.stack_arrays funktioniert nicht gut, entweder

Schreibe einen Kommentar