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

josef.pktd@gmai... josef.pktd@gmai...
Wed Sep 16 04:10:43 CDT 2009


On Wed, Sep 16, 2009 at 4:42 AM, Pierre GM <pgmdevlist@gmail.com> wrote:
>
> On Sep 16, 2009, at 4:25 AM, josef.pktd@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@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list