Python 带有列的数据透视表中的小计
我想得到“小计”和基于列的总计,但我只得到总值Python 带有列的数据透视表中的小计,python,pivot,Python,Pivot,我想得到“小计”和基于列的总计,但我只得到总值 data = pd.pivot_table(data,index=['ACTION_DATE'],columns=[ "USER_ID","RESULT"], values=["S"] ,aggfunc=["count"],fill_value="0", margins=True, margins_name= 'Grand Total') 预期结果
data = pd.pivot_table(data,index=['ACTION_DATE'],columns=[ "USER_ID","RESULT"], values=["S"] ,aggfunc=["count"],fill_value="0", margins=True, margins_name= 'Grand Total')
预期结果: