state_office = df.groupby(['state', 'office_id']).agg({'sales': 'sum'})
state_pcts = state_office.groupby(level=0).apply(lambda x: 100 * x / float(
    x.sum()))
Pandas percentage of total with groupby