I have a multi-index dataframe and want to sum the values. If there aren't rows for that I need to show 0 like in the example below
import pandas as pd
d = {'City': ['Tokyo','Tokyo','Lisbon','Tokyo','Madrid','New York','Madrid','London','Tokyo','London','Tokyo'],
'Card': ['Visa','Visa','Visa','Master Card','Bitcoin','Master Card','Bitcoin','Visa','Master Card','Visa','Bitcoin'],
'Colateral':['Yes','Yes','No','No','Yes','No','No','Yes','Yes','No','Yes'],
'Client Number':[1,2,3,4,5,6,7,8,9,10,11],
'Total':[100,100,200,300,10,20,40,50,60,100,500]}
df = pd.DataFrame(data=d)
df.set_index(['City','Card','Colateral']).drop(['Client Number'],axis=1)
df.sum(level=[0,1])
The result I wish to accomplish is something like this
