pd.pivot_table(df5,index=['key1','key2'],values=['data1','data2'],aggfunc=[np.sum,np.mean],margins=True)
margins=True 会有加和后的数据
参考文章
http://python.jobbole.com/81212/
pd.pivot_table(df5,index=['key1','key2'],values=['data1','data2'],aggfunc=[np.sum,np.mean],margins=True)
margins=True 会有加和后的数据
参考文章
http://python.jobbole.com/81212/
转载于:https://www.cnblogs.com/fatcici2017/p/6648014.html