[Numpy-discussion] how can we concatenate structured arrays ?

josef.pktd at gmail.com josef.pktd at gmail.com
Wed Sep 16 05:10:43 EDT 2009


On Wed, Sep 16, 2009 at 4:42 AM, Pierre GM <pgmdevlist at gmail.com> wrote:
>
> On Sep 16, 2009, at 4:25 AM, josef.pktd at gmail.com wrote:
>
>> I have two structured arrays of different types. How can I
>> horizontally concatenate the two arrays? Is there a direct way, or do
>> I need to start from scratch?
>
> Check numpy.lib.recfunctions, that should get you started.

Thanks, I was doing that, but without reading through every option
of every function, they all seem to do something more
complicated, like merge or joinby,
append_fields doesn't look very convenient, adds one by one

looking some more recursive_fill_fields seems also to do the
loop (but also handles nested structured arrays)

tt = np.empty((10,1),dt2)
numpy.lib.recfunctions.recursive_fill_fields(testdata, tt)
numpy.lib.recfunctions.recursive_fill_fields(testdatacont, tt)

So, I guess the answer is, loop over columns of structured arrays

Josef

> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



More information about the NumPy-Discussion mailing list