1

I have two numpy arrays:

a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])
b = np.array([[1, 2, 3], [0, 1, 6], [3, 3, 3], [4, 5, 6]] )

How do I go about finding out the common rows between the two arrays? So, for these two sample arrays, the result should be:

[[1, 2, 3], [4, 5, 6]]

I searched on StackOverflow, but only saw solutions to find out unique rows in one array instead of two arrays...I figured there's a way to iterate through the first array and compare with second array, but that must be hugely inefficient compared with a native numpy way of doing things. Any help is appreciated.

Divakar
  • 218,885
  • 19
  • 262
  • 358
George Liu
  • 3,601
  • 10
  • 43
  • 69

0 Answers0