I'm trying to filter a 2D numpy array with another 2D numpy arrays values. Something like this:
array1 = np.array([[ 0, 0],
[86, 4],
[75, 74],
[78, 55],
[53, 94],
[49, 83],
[99, 75],
[99, 10],
[32, 4],
[55, 99],
[62, 95],
[ 0, 0]])
array2 = np.array([[55, 99],
[32, 4],
[75, 74]])
array1[np.isin(array1, array2[2:5]).all(axis=1) == 0]
My ideal output would be a filtered version of array1 that does not have the rows which are equal to the ones in the array2 slice. Problem is when i do it like this:
np.isin(array1, array[2:5])
output is:
array([[False, False],
[False, True],
[ True, True],
[False, True],
[False, False],
[False, False],
[ True, True],
[ True, False],
[ True, True],
[ True, True],
[False, False],
[False, False]])
It wrongly classifies [99,75] row as [True, True] because both of those values individually exist in our array2. Is there a more correct way to filter based on all values of a row?