[Numpy-discussion] stacking record arrays

Benjamin Root ben.root@ou....
Mon Jun 21 13:58:52 CDT 2010


On Mon, Jun 21, 2010 at 1:51 PM, Robert Kern <robert.kern@gmail.com> wrote:

> On Mon, Jun 21, 2010 at 13:44, Benjamin Root <ben.root@ou.edu> wrote:
> > Hello,
> >
> > I ran into a somewhat counter-intuitive situation that probably should be
> > documented somewhere with respect to record (structured?) arrays.  I
> wanted
> > to stack multiple arrays together that had the same names for the
> columns.
> > Since I was imagining the columns as having the names (as opposed to
> rows),
> > I figured vstack() would do the job, but it merely created a sequence of
> > record arrays.  Turns out that I had to use hstack() to get what I
> wanted.
>
> Remember that your structured arrays are simply 1-D vectors of
> records. 1-D vectors are primarily treated as row vectors by things
> that care about "horizontal" and "vertical" for all dtypes, both
> records and "normal" scalars. It just gets a bit confusing because one
> often thinks of 1-D arrays of records as being rows and columns.
>
>
Yeah, that's what I ended up realizing after I noticed my output from vstack
wasn't what I expected, which made me try out hstack instead.

Thanks,
Ben Root


> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
>  -- Umberto Eco
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100621/2e30fcc0/attachment-0001.html 


More information about the NumPy-Discussion mailing list