I have a dataframe with 10 columns (in which the last column is the sum of all the values in each row), and I need to divide each value of the dataframe by the corresponding total column.
Cluster 1 2 3 4 5 6 7 8 9 Total
Sector
1 3 2 1 3 1 2 1 1 2 16
2 2 2 2 3 1 2 1 1 2 16
3 1 1 1 3 1 2 1 1 2 13
4 4 1 1 3 1 2 1 1 2 16
5 3 2 3 3 1 2 1 1 2 18
And I need the new dataframe as:
Cluster 1 2 3 4 5 6 7 8 9 Total
Sector
1 3/16 2/16 1/16 3/16 1/16 2/16 1/16 1/16 2/16 16
2 2/16 2/16 2/16 3/16 1/16 2/16 1/16 1/16 2/16 16
3 1/13 1/13 1/13 3/13 1/13 2/13 1/13 1/13 2/13 13
4 .....
5 ....