I read the similar topic here. I think the question is different or at least .index() couldnot solve my problem.
.index()
This is a simple code in R and its answ
Numpy does have built-in functions for it
x = [1,2,3,4,0,1,2,3,4,11] x=np.array(x) np.where(x == 2) np.min(np.where(x==2)) np.argmin(x) np.where(x == 2) Out[9]: (array([1, 6], dtype=int64),) np.min(np.where(x==2)) Out[10]: 1 np.argmin(x) Out[11]: 4