[Numpy-discussion] selecting part of an array like a[ a<5 ]
markbak at gmail.com
Mon Aug 20 09:05:54 EDT 2007
Hello - I am wondering what the better way is to select part of an
Say I have an array a:
a = arange(10)
Now I want to select the values larger than 5
a[ a>5 ]
and later I need the values smaller or equal to 5
a[ a<=5 ]
It seems that doing the comparison twice is extra work (especially if
the array is large).
So I thought I store the comparison
b = a>5
Now I can do
But how do I get the others?
a[not b] or a[!b] don't work. So it's gotta be something different.
Besides, is it a good idea to store b like I suggest?
Thanks for the help,
More information about the NumPy-Discussion