So I want to write a function that performs z-score transformation for each element in an array and the function should return an array of the result. When I perform the transformation to every element in the array using a for loop its not a problem.
x1 = np.array([[4,3,12],[1,5,20],[1,2,3],[10,20,40],[7,2,44]])
mean = np.average(x1)
std = np.std(x1)
for i in x1:
arr1 = ((i-mean)/std)
print(arr1)
type(arr1)
However when I use a for loop for the column 1 of the array I get float values.
for x in x1[:,1]:
arr2 = ((i-mean)/std)
print(arr2)
type(arr2)
What can I do to make sure arr2 that is returned is a 1 dimensional array.