Is there an equivalent function of find(A>9,1)
from matlab for numpy/scipy. I know that there is the nonzero
function in numpy but what I need is th
matlab's find(X, K)
is roughly equivalent to numpy.nonzero(X)[0][:K]
in python. @Pavan's argmax method is probably a good option if K == 1
, but unless you know apriori that there will be a value in A >= 9, you will probably need to do something like:
idx = (A >= 9).argmax()
if (idx == 0) and (A[0] < 9):
# No value in A is >= 9
...