The below code checks if each element of sub-arrays is greater than 2 and gives the result in their respective sub-arrays:
2d_array=np.array([[1,2,3,4],[4,56,7,1]])
for elem in 2d_array:
print(elem[elem[:]>2])
Output:
[3 4]
[ 4 56 7]
Can we do the same without using a for loop, Preferably using numpy functions.