[Numpy-discussion] index of the first element fulfilling a condition?
Wed Aug 18 13:07:48 CDT 2010
is there a good method to find the index of the first element in a 1D
array fulfilling a condition?
The following does the job
>>> import numpy
>>> a = numpy.array([1,5,78,3,12,4])
>>> numpy.where( a>10 )
but it first compares the entire array and then selects the first index.
Is there a way (especially for big arrays) to stop the comparison after
the first hit?
Thanks for any help, Johann
More information about the NumPy-Discussion