0

How can I find those row indices of numpy array a that are not already in ref?

For instance for this example:

ref = np.asarray([[1.1, 2.2, 3.3], [4, 5, 6]])
a = np.asarray([[0, 1, 2], [1.1, 2.2, 3.3], [4, 5, 5]])

A result of [0, 2] would be correct, because these rows in a are not in ref. A possible solution would be to iterate over each row in a and check if it's in ref, but I was hoping there's a more efficient and elegant (1-liner?) way.

Note: This answer doesn't work because it is assuming integer elements of the array (in my case I use floating point numbers).

orange
  • 7,755
  • 14
  • 75
  • 139
  • There's an efficient 2-liner in the above link. – jpp Mar 02 '18 at 03:04
  • Ok, slight alteration to my initial question: I actually use floating point values in which case your suggestion doesn't work (will update my example). – orange Mar 02 '18 at 04:49
  • Actually, there's a range of options suggested at your link. One seems to be working fine. I guess this can be deleted as suggested. – orange Mar 02 '18 at 05:06

0 Answers0