a = df.groupby(['userid', 'week'])['quiz_score'].agg(('sum', 'count'))
a = a.reindex(pd.MultiIndex.from_product([['1', '2'], list(range(1, 7))], names=[
    'userid', 'week']))
b = a.groupby(level=0).cumsum().groupby(level=0).shift(1)
Expanding mean grouped by multiple columns in pandas