Answers for "check if any values overlap in numpy array"

1

check if any values overlap in numpy array

import numpy as np
array_1 = np.array(((1, 2, 3), (4, 5, 6), (7, 8, 9)))
array_2 = np.array(((3, 1, 2), (5, 4, 6), (7, 9, 8)))
#In this example, array_2 does have some of the same elements(i.e. the 6s and 7s are in the same place)
#This means that when we check if any of their elements are the same, we will get True.
print(np.any(array_1 == array_2))
#output is True
print(np.all(array_1 == array_2))
#output is False
Posted by: Guest on August-19-2021

Code answers related to "check if any values overlap in numpy array"

Python Answers by Framework

Browse Popular Code Answers by Language