[SciPy-User] noob Needs guru for array manipulation

Jean-Baptiste BUTET ashashiwa at gmail.com
Sun Dec 11 07:47:33 EST 2011


thanks Emmanuelle ... this is exactly that.

JB

2011/12/11 <josef.pktd at gmail.com>

> On Sun, Dec 11, 2011 at 7:31 AM, Emmanuelle Gouillart
> <emmanuelle.gouillart at normalesup.org> wrote:
> > Hi,
> >
> > I'm not sure I understand your example (under 120 in algebraic
> > or
> > absolute value? Why don't you remove the last column which has 0 on
> > the
> > second line?), but the syntax would
> > be
> >
> >>>> import numpy as
> >>>> np
> >>>> a = np.array([[1, 2, 3], [160, 30,
> >>>> 125]])
> >>>> b = a[:, a[1] >
> >>>> 120]
> >>>>
> >>>> b
> > array([[  1,
> > 3],
> >        [160,
> > 125]])
> >
> > b = a[:, a[1] > 120] is called fancy indexing. For an introduction
> > to
> > numpy arrays, see for
> > example
> > http://scipy-lectures.github.com/intro/numpy/numpy.html
>
> and
>
> http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html
> http://mentat.za.net/numpy/intro/intro.html
>
> Josef
>
> >
> > Cheers,
> > Emmanuelle
> >
> > 2011/12/11 Jean-Baptiste BUTET <ashashiwa at gmail.com>
> >>
> >> Hi all :)
> >>
> >> I have this array :
> >> [[  0.00000000e+00 ,  2.26757370e-05  , 4.53514739e-05 ,
> >> 2.27548753e+00   , 2.27551020e+00  , 2.27553288e+00]
> >>  [ -1.38700000e+03  , -1.51300000e+03 , -1.52600000e+03 ,
> >> 3.39000000e+02,  1.11000000e+02   0.00000000e+00]
> >>
> >> I would like to remove couples where results in 2nd row are under 120 :
> >>
> >> [[  0.00000000e+00 ,  2.26757370e-05  , 4.53514739e-05 ,
> >> 2.27548753e+00    , 2.27553288e+00]
> >>  [ -1.38700000e+03  , -1.51300000e+03 , -1.52600000e+03 ,
> >> 3.39000000e+02,     0.00000000e+00
> >>
> >> I don't really understand numpy array philosophia... so I need help here
> >> :)
> >>
> >> Thanks.
> >>
> >> JB
> >>
> >> _______________________________________________
> >> SciPy-User mailing list
> >> SciPy-User at scipy.org
> >> http://mail.scipy.org/mailman/listinfo/scipy-user
> >>
> >
> >
> > _______________________________________________
> > SciPy-User mailing list
> > SciPy-User at scipy.org
> > http://mail.scipy.org/mailman/listinfo/scipy-user
> >
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at 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/20111211/2cd69ccd/attachment.html>


More information about the SciPy-User mailing list