colors = pd.unique(df.columns.get_level_values('color'))
for attr in attributes:
    for clr in colors:
        df[attr, clr, 'sum'] = df.xs([attr, clr], level=['attribute',
            'color'], axis=1).sum(axis=1)
df
Add subtotal columns in pandas with multi-index