[Numpy-discussion] Compound conditional indexing
Christopher Barker
Chris.Barker at noaa.gov
Wed Sep 30 14:41:50 EDT 2009
Gökhan Sever wrote:
> How to conditionally index an array as shown below :
>
> a = arange(10)
> a[5<a<8]
>
> to get
> array([6,7])
In [56]: a[(5<a) & (a<8)]
Out[56]: array([6, 7])
not as efficient as it might be, but it works.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the NumPy-Discussion
mailing list