Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 带有列的数据透视表中的小计_Python_Pivot - Fatal编程技术网

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')
预期结果: