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
  • 212,295
  • 18
  • 231
  • 332
George Liu
  • 3,331
  • 7
  • 40
  • 65

0 Answers0