Skip to content
Advertisement

In Pandas sum columns and change values to proportion of sum

If I have the following DataFrame, how can I convert the value in each row to the proportion of the total of the columns?

Input:

JavaScript

Output:

JavaScript

Advertisement

Answer

How about apply?

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement