0
votes
val country by columnOf("UK", "UK", "FR", "FR", "DE")
val city by columnOf("London", "London", "Paris", "Paris", "Bonn")
val area by columnOf("Holborn", "Camden", "Barbes", "Eiffel", "Weststadt"), 
val population by columnOf(1100, 1200, 1300, 1400, 1500) 

val df = dataFrameof (country, city, area, population) 
println(df) 

How can I add a column which is population / sum by (country, city). This column would be calculated as follows:

Proportion
0.47826087  (i.e. 1100/2300)
0.52173913
0.481481481
0.518518519
1.00