I want to divide the sum of two columns in pyspark. For example, I have a datasets like below:
A B C
1 1 2 3
2 1 2 3
3 1 2 3
What I want is to get sum of colA divide by sum of colB as below:
6 (Sum of colB) / 3 (Sum of colA) = 2
I have tried this:
sumofA = df.groupby().sum('A')
sumofB = df.groupby().sum('B')
Result = B / A
but it produces this error:
TypeError: unsupported operand type(s) for /: 'DataFrame' and 'DataFrame'