def add_group(group):
c = group.c.astype('float')
group['d'] = c/c.sum()
return group
df = pd.DataFrame({'a':[3,4,5,2,5,3], 'b':[3,2,1,2,2,3]})
df['c'] = [10,49,58,28,15,25]
dfff= df.groupby(['a','b']).apply(add_group)
def add_group(group):
c = group.c.astype('float')
group['d'] = c/c.sum()
return group
df = pd.DataFrame({'a':[3,4,5,2,5,3], 'b':[3,2,1,2,2,3]})
df['c'] = [10,49,58,28,15,25]
dfff= df.groupby(['a','b']).apply(add_group)