I have a dataframe:
Time Weight
1 4
2 2
3 1
4 7
How can I normalize the weight column, so that the sum of the values in the weight column are equal to 1 ?
I have a dataframe:
Time Weight
1 4
2 2
3 1
4 7
How can I normalize the weight column, so that the sum of the values in the weight column are equal to 1 ?
You can divide each values in the Weight
column by sum
of all the values in the Weight
column,
df['Weight']/df['Weight'].sum()
0 0.285714
1 0.142857
2 0.071429
3 0.500000
Name: Weight, dtype: float64