Given m x n numpy array
X = np.array([
[1, 2],
[10, 20],
[100, 200]
])
how to find index of a row, i.e. [10, 20] -> 1?
n could any - 2, 3, ..., so I can have n x 3 arrays
Y = np.array([
[1, 2, 3],
[10, 20, 30],
[100, 200, 300]
])
so I need to pass a vector of size n, in this case n=3, i.e a vector [10, 20, 30] to get its row index 1? Again, n could be of any value, like 100 or 1000.
Numpy arrays could be big, so I don't want to convert them to lists to use .index()
[10, 20]then you refer to a vector[10, 20, 30]: is the query tensor you are using to find the index of variable size?np.where((X[:,0] == 10) & (X[:,1] == 20))do the job, but I don't know how to make a condition to handle arbitrary number n of elements in a vector, i.e. how given a vector[10, 20, 30]automatically get a condition like(Y[:,0] == 10) & (Y[:,1] == 20) & (Y[:,2] == 30)