[SciPy-User] naming columns in array

Benjamin Root ben.root@ou....
Fri Sep 10 20:12:23 CDT 2010


On Fri, Sep 10, 2010 at 6:28 PM, <josef.pktd@gmail.com> wrote:

> On Fri, Sep 10, 2010 at 7:21 PM, Dan Lussier <dtlussier@gmail.com> wrote:
> > I was wondering if there was possible to change the dtpye of an array
> > once it exits.
> >
> > Here is my situation.
> >
> > I have either a N x 1 column, or a N x M array where I would like to
> > be able to name the columns after the array exists.
> >
> > I have tried working with record arrays a bit, but no luck.  If
> > someone might be able to scratch a quick example I'd be grateful.
>
> creating a view with structured dtype
>
> >>> x = np.array([[1, 2],[3,4]])
> >>> x.view(dtype=[('a', np.int32), ('b', np.int32)])
> array([[(1, 2)],
>       [(3, 4)]],
>      dtype=[('a', '<i4'), ('b', '<i4')])
>
>

Maybe a labeled array (a.k.a. - larry)?  larry, the manual — la v0.4.0
documentation <http://larry.sourceforge.net/>

Ben Root

> Josef
>
> >
> > Thanks!
> > _______________________________________________
> > SciPy-User mailing list
> > SciPy-User@scipy.org
> > http://mail.scipy.org/mailman/listinfo/scipy-user
> >
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100910/3c8b6b16/attachment-0001.html 


More information about the SciPy-User mailing list