[Numpy-discussion] Find insertion point

Lane Brooks lane@brooks...
Tue Aug 17 11:39:47 CDT 2010


On 08/17/2010 09:53 AM, Nikolaus Rath wrote:
> Hello,
>
> I want to find the first i such that x[i]<  y and x[i+1]>= y. Is there
> a way to do this without using a Python loop?
>
> I can't use np.searchsorted(), because my x array crosses y several
> times.
>
>
> Best,
>
>     -Nikolaus
>


i = numpy.nonzero(x>=y)[0][0]




More information about the NumPy-Discussion mailing list