I am trying to find the index of a number that is greater than 10 but the next value is less than 10:
py = np.array([ 9.7, 10.1, 10.5, 10.2, 10.1, 9.9, 9.8])
So the answer should be 4. However, the output I got was 0. How do I fix the error?
for k in range(0,len(py)):
if py[k]>10 and py[k+1]<10:
position_y = np.argmax(k)
print(position_y)
np.argmax. It's not clear what you expect it to do here. Really you can justprint(k)numpy.argmax()function returns indices of the max element of the array in a particular axis.