I have an array
a=[1,2,3,4,5,6,7,8,9]
and I want to find the indices of s satisfying two conditions: i.e.
a>3 and a<8 ans=[3,4,5,6] a[ans]=[4,5,6,7]
I can use numpy.nonzero(a>3) or numpy.nonzero(a<8) but there is no numpy.nonzero(a>3 and a<8) , which gives an error:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
When I try to use any or all , I get the same error. Is it possible to combine two conditional tests to get ans?
python numpy find
David Jul 14 '10 at 16:55 2010-07-14 16:55
source share