[Numpy-discussion] Find insertion point

Alan G Isaac alan.isaac at gmail.com
Tue Aug 17 12:35:13 EDT 2010


On 8/17/2010 11:53 AM, Nikolaus Rath wrote:
> 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?


argmax? (to get i+1):
         >>> d = np.linspace(0,10,101)
         >>> x = np.sin(d)
         >>> np.argmax(x>=0.5)
         6

fwiw,
Alan Isaac




More information about the NumPy-Discussion mailing list