[Numpy-discussion] selecting part of an array like a[ a<5 ]
Mon Aug 20 08:05:54 CDT 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