numpy NOOB.
How best to see if an element exists in a numpy array?
Example:
import numpy as np
a = np.array([[1, 2], [2, 3], [3, 4]])
[2, 4] in a
# This evaluates to True because there's
# a 2 (somewhere) and a 4 (somewhere)
# but I want to match [2, 4] ONLY. So...
[2, 4] in a # Would like this to be False
[2, 3] in a # Would like this to be True
[3, 2] in a # This too should be false (wrong order [3, 2] != [2, 3])
I've looked at np.where()
and that doesn't seem to be what I'm looking for. I get a similar result to the above using np.isin([2, 4], a)
.
Don't need the index (though if it comes along for the ride that OK), just a boolean will suffice.