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 use any built-in function and list comprehension:
any
>>> 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] >>> any(i in array2 for i in array1) True