[Numpy-discussion] Compound conditional indexing

Joe Kington jkington@wisc....
Wed Sep 30 13:32:18 CDT 2009


There may be a more elegant way, but:

In [2]: a = np.arange(10)

In [3]: a[(a>5) & (a<8)]
Out[3]: array([6, 7])


On Wed, Sep 30, 2009 at 1:27 PM, Gökhan Sever <gokhansever@gmail.com> wrote:

> Hello,
>
> How to conditionally index an array as shown below :
>
> a = arange(10)
> a[5<a<8]
>
> to get
> array([6,7])
>
> I can't do this with where either.
>
> What is the cure for this?
>
> Thanks.
>
> --
> Gökhan
>
> _______________________________________________
> 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/20090930/0749ea1e/attachment.html 


More information about the NumPy-Discussion mailing list