x1 = [{'id1': 'Africa', 'id2': 'Europe', 'v': 1},
{'id1': 'Europe', 'id2': 'North America', 'v': 5},
{'id1': 'North America', 'id2': 'Asia', 'v': 2,},
{'id1': 'North America', 'id2': 'Asia', 'v': 3}]
df = pd.DataFrame(x1)
How would I group by continents and get the total sum based on column 'v'?
For example, I would expect to get sum of values for each continent as follow:
Africa: 1 (1)
Europe: 6 (1 + 5)
North America: 10 (5 + 2 + 3)
Europe: 6 (1 + 5)