[SciPy-User] noob Needs guru for array manipulation

Emmanuelle Gouillart emmanuelle.gouillart at nsup.org
Sun Dec 11 07:29:22 EST 2011


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

Cheers,
Emmanuelle
 
On Sun, Dec 11, 2011 at 01:15:51PM +0100, Jean-Baptiste BUTET wrote:
>    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




More information about the SciPy-User mailing list