So I have a data frame called df. It looks like this.
0 | 1 | 2 |
---|---|---|
1 | 2 | 3 |
4 | 5 | 6 |
7 | 8 | 9 |
I want to sum up the columns and divide the sum of the columns by the sum of the rows. So for example: row 1, column 0: (1+4+7)/(1+2+3) row 2, column 0: (1+4+7)/(4+5+6)
so on and so forth.
so that my final result is like this.
0 | 1 | 2 |
---|---|---|
2 | 2.5 | 3 |
0.8 | 1 | 1.2 |
0.5 | 0.625 | 0.75 |
How do I do it in python using pandas and dataframe?