Get index of 2d Numpy array with 1d array

Viewed 70

Say I have a np array

arr = np.array([[1,2,3],
                [4,5,6],
                [7,8,9],
                [1,2,3]])

if i have another numpy array

a = np.array([1,2,3])

How could I find the indexes of arr that matches a I've tried the following but it returns two arrays

# desired output [0,3]
result = np.where(arr==a)

#results
#(array([0, 0, 0, 3, 3, 3], dtype=int64),
#array([0, 1, 2, 0, 1, 2], dtype=int64))
0 Answers
Related