Suppose I have an array A
of shape (M, K)
and another B
of shape (N, K)
.
The rows of B
are all the possible patterns that can be encountered (each pattern is thus a 1D array of size K
).
I thus would like to get an array C
of shape (M,)
where C[i]
is the indice of the pattern (in B
) of row i
in A
.
I am currently doing this in a loop (i.e. looping over all the possible patterns) but I would end up using vectorization.
Here is an example:
A = np.array([[0, 1], [0, 1], [1, 0]])
B = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
I am expecting:
C = np.array([1, 1, 2])