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).

3
  • There's an efficient 2-liner in the above link. Commented Mar 2, 2018 at 3: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). Commented Mar 2, 2018 at 4: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. Commented Mar 2, 2018 at 5:06

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.