What is the best way to check if an numpy array contains any element of another array?
example:
array1 = [10,5,4,13,10,1,1,22,7,3,15,9] array2 = [3,4,9,1
You can try this
>>> array1 = [10,5,4,13,10,1,1,22,7,3,15,9] >>> array2 = [3,4,9,10,13,15,16,18,19,20,21,22,23] >>> set(array1) & set(array2) set([3, 4, 9, 10, 13, 15, 22])
If you get result means there are common elements in both array.
If result is empty means no common elements.