I have two large 1d numpy arrays in the range of 400K elements. I need to check for each element in array A if it exists in array B. I used in1d but it seems to be too slow and takes a lot of time. I would like to know if there is any way to speed this up?
A = np.array([1,2,3,4,5,6,7])
B = np.array([3,4,7])
result = np.in1d(A, B, invert=True)
result
>> array([ True, True, False, False, True, True, False]