I am using python and I have a matrix and would like to normalize individual columns in it between [-1,1]
a = matrix
([[3, 2, 4, 6]
[4, 5, 6, 5]
[6, 4, 5, 3]
[3, 5, 6, 7]])
I applied
a = a / np.linalg.norm(a, axis=0, keepdims=True)
and the a was normalized between [0,1]
however, I would like to do something like .apply(lambda x: np.where(x>0,x/x.max(),np.where(x<0,-x/x.min(),x))) so that it can get normalised between [-1,1] and the zero position is the same.
but it is not possible to use
.apply
in a matrix, how can I overcome it?