For example, I have two arrays
A= [[1,0],[2,0],[3,0]] B=[[2,1],[2,0],[3,0]] np.intersect1d(A,B) gives me 0,1,2,3, but what I actually want is [2,0] and [3,0]. What can I do in this case?
Here is one way:
set([tuple(row) for row in A]).intersection([tuple(row) for row in B]) {(3, 0), (2, 0)} You can then get this as an np.array like this:
tups = set([tuple(row) for row in A]).intersection([tuple(row) for row in B]) result = np.array([tup for tup in tups]) >>> result array([[3, 0], [2, 0]])