構造化配列を最初から作成して埋めるのがおそらく最善です。
2 つの例は、次のように始まります。
import numpy as np
from numpy.lib import recfunctions
ints = np.ones(5,dtype=np.int)
floats = np.ones(5,dtype=np.float)
strings = np.array(['A']*5)
空の構造化配列を作成して値を入力するには:
out=np.empty(5,dtype=[('ints', '>i4'), ('floats', '>f8'), ('strings', '|S4')])
out['ints']=ints
out['floats']=floats
out['strings']=strings
print out
[(1, 1.0, 'A') (1, 1.0, 'A') (1, 1.0, 'A') (1, 1.0, 'A') (1, 1.0, 'A')]
print out.dtype
[('ints', '>i4'), ('floats', '>f8'), ('strings', 'S4')]
現在の配列にデータを追加するには:
out=np.lib.recfunctions.append_fields(ints,['floats','strings'],[floats,strings])
print out
[(1, 1.0, 'A') (1, 1.0, 'A') (1, 1.0, 'A') (1, 1.0, 'A') (1, 1.0, 'A')]
print out.dtype #note the name applied to the first array
[('f0', '>i4'), ('floats', '>f8'), ('strings', 'S4')]
構造化配列を扱うには、python pandasを強くお勧めします。