import numpy as np
nums1 = np.random.randint(0,6,(6,4))
nums2 = np.random.randint(0,6,(2,3))
print("Original arrays:")
print(nums1)
print("\n",nums2)
temp = (nums1[..., np.newaxis, np.newaxis] == nums2)
rows = (temp.sum(axis=(1,2,3)) >= nums2.shape[1]).nonzero()[0]
print("\nRows of a given array that contain elements of each row of another given array:")
print(rows)
Sample Output:
Original arrays:
[[5 2 5 1]
[5 4 1 3]
[0 1 1 1]
[2 0 4 0]
[2 5 1 5]
[4 0 4 0]]
[[2 3 1]
[1 1 4]]
Rows of a given array that contain elements of each row of another given array:
[0 1 2 4]
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer