For a two-dimensional array, I'm trying to make a standardize-function, which should work row-wise and column-wise. I'm not sure what to do when an argument is given with axis=1 (row-wise).
def standardize(x, axis=None):
if axis == 0:
return (x - x.mean(axis)) / x.std(axis)
else:
?????
I tried to change axis
to axis = 1
in this part: (x - x.mean(axis)) / x.std(axis)
But then I got the following error:
ValueError: operands could not be broadcast together with shapes (4,3) (4,)
Can someone explain to me what to do as I'm still a beginner?