df_summed = {
let countryList = z.unique(z.getCol("Country", countryStat))
let varList = z.unique(z.getCol("Variable", countryStat))
let columnNames = ["country", "inflow", "outflow", "stock"]
let sums = []
for (var i = 0; i < countryList.length; i++)
{
let currRow = {country: countryList[i],
inflow: 0,
outflow: 0,
stock: 0}
let tag = ""
for (var j = 0; j < varList.length; j++)
{
tag = varList[j] + countryList[i]
currRow[columnNames[j+1]] = z.getCol("sum", (z.filter(r => r["group"] == tag, migrationSums)))[0]
}
sums.push(currRow)
}
return sums
}