numpy apply function to each element of numpy array code example
Example: numpy apply function to array
import numpy as np
arr = np.array([1,2,3,4])
print(np.apply_along_axis(lambda x : x ** 2, 0, arr))
#Output: array([ 1, 4, 9, 16])
import numpy as np
arr = np.array([1,2,3,4])
print(np.apply_along_axis(lambda x : x ** 2, 0, arr))
#Output: array([ 1, 4, 9, 16])