I am trying to add a sum to my multiindex dataframe by each grouping
Count
state car status
texas civic New 11
undamaged 11
damaged 10
totalled 5
virginia civic New 10
undamaged 20
damaged 10
totalled 5
I want it to look like:
Count
state car status
texas civic New 11
damaged 10
totalled 5
undamaged 11
total 37
virginia civic New 10
damaged 10
totalled 5
undamaged 20
total 45
I have tried
s = test.groupby(level=[0,1]).sum()
s.index = pd.MultiIndex.from_product([s.index, ['Total']])
df_out = df_full.append(s).sort_index()
but it throws
NotImplementedError: isna is not defined for MultiIndex