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
Here is what the above code is Doing:
1. We create two arrays, array_1 and array_2.
2. We use the np.any() function to check if any of the elements in array_1 and array_2 are the same.
3. We use the np.all() function to check if all of the elements in array_1 and array_2 are the same.