groupie
2017-12-28 15:34 xplorerthik 阅读(187) 评论(0) 编辑 收藏 举报 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)