I know there is a method for a Python list to return the first index of something:
>>> l = [1, 2, 3] >>> l.index(2) 1
Is
For 1D arrays, I'd recommend np.flatnonzero(array == value)[0], which is equivalent to both np.nonzero(array == value)[0][0] and np.where(array == value)[0][0] but avoids the ugliness of unboxing a 1-element tuple.
np.flatnonzero(array == value)[0]
np.nonzero(array == value)[0][0]
np.where(array == value)[0][0]