[Numpy-discussion] How to concatenate 2 recarrays into a single recarray
derek at astro.physik.uni-goettingen.de
Thu May 11 15:12:16 EDT 2017
On 11 May 2017, at 8:52 pm, Isaac Gerg <isaac.gerg at gergltd.com> wrote:
> Looking at the code, i think merge and stack take in ndarrays, not recarrays
> is that correct?
It should accept either; however if your a and b are two recarrays with all uniquely named columns
to get the 10-column recarray in your original example you should do
newtable = np.lib.recfunctions.merge_arrays([a, b], flatten=True, asrecarray=True)
otherwise newtable will be a recarray of two columns with 5 nested subcolumns each
(i.e. each column will have a dtype [(‘col0’, ‘<f8’), (‘col1’, … (‘col4, ‘<f8’)])
Duplicate column names will raise an error with ‘flatten=True’.
More information about the NumPy-Discussion