Python – Normalize columns of a dataframe


I have a dataframe in pandas where each column has different value range. For example:


A     B   C
1000  10  0.5
765   5   0.35
800   7   0.09

Any idea how I can normalize the columns of this dataframe where each value is between 0 and 1?

My desired output is:

A     B    C
1     1    1
0.765 0.5  0.7
0.8   0.7  0.18(which is 0.09/0.5)

Best Answer

one easy way by using Pandas: (here I want to use mean normalization)


to use min-max normalization:


Edit: To address some concerns, need to say that Pandas automatically applies colomn-wise function in the code above.

Related Question