As an alternative, there are helper utilities numpy.lib.recfunctions that I came across. This module has functions for merging and stacking recarrays :
from numpy.lib.recfunctions import stack_arrays c = stack_arrays((a, b), asrecarray=True, usemask=False) c.foo >>> array([ 140239282560000, 4376479720, -4611686018427387904, 4358733828, 4365061216])
If you want to add additional columns to recarray , this can be done with merge_arrays :
import numpy as np from numpy.lib.recfunctions import merge_arrays dt1 = [('foo', int), ('bar', float)] dt2 = [('foobar', int), ('barfoo', float)] aa = np.empty(6, dtype=dt1).view(np.recarray) bb = np.empty(6, dtype=dt2).view(np.recarray) cc = merge_arrays((aa, bb), asrecarray=True, flatten=True) type(cc) >>> numpy.core.records.recarray
(Although this is not an answer to the question, I am posting the last example as a reference)
Tim
source share