I am looking for a way to find means of each column in a python dataframe and subtract that column with the mean of that column.
Suppose I have:
df = pd.DataFrame({'a': [1.5, 2.5], 'b': [0.25, 2.75], 'c': [1.25, 0.75]})
I want to find the mean of each column, which would return (2,1.5,1)
and subtract the values from columns a
,b
and c
respectively.
which would give, ((-0.5,0.5),(-1.25, 1.5), (0.25,-0.25))
Can anybody help me in doing this?
Thanks