If I have a numpy array like this:
import numpy as np
x = np.array([[0,1],[0,2],[1,1],[0,2]])
How can I return the index of the first row that matches [0,2]?
For lists it's easy using index:
[[0,1],[0,2],[1,1],[0,2]]
l.index([0,2])
> 1
And I know numpy has the function numpy.where, but I'm not really sure what to make of the output of numpy.where:
np.where(x==[0,2])
> (array([0, 1, 1, 3, 3]), array([0, 0, 1, 0, 1]))
There's also numpy.argmax, but that also doesn't return what I'm looking for, which is simply the index 1
np.argmax(x == [0,2], axis = 1)