Can we add a subtotal functions for margins in pivot table function?

23 views
Skip to first unread message

Jingjing Liu

unread,
Jun 6, 2018, 8:12:28 PM6/6/18
to PyData
Hello,

I am seeking the solution for a subtotal margins in the pivot table function (please see my original question post in: https://stackoverflow.com/questions/50730502/create-subtotals-for-rows-in-pivot-table-for-different-columns/50730602?noredirect=1#comment88469730_50730602). 

I am wondering if this is something which can be added to the pivot table functions, I know Excel has this sort of function while embed a pivot table inside a major pivot table (or sub-margins within grandtotals)? Thanks.

-J

Tom Augspurger

unread,
Jun 7, 2018, 8:47:11 AM6/7/18
to pyd...@googlegroups.com
I don't think DataFrames are a good container for summary results like this. In the SO example, you've had to convert your DatetimeIndex to an object index to accommodate the "all" item.

It'd be better to have a dedicated Summary type that has special rules & data representation around the "subtotal" columns, though I'm not sure this belongs in pandas itself.

--
You received this message because you are subscribed to the Google Groups "PyData" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pydata+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jingjing Liu

unread,
Jun 7, 2018, 11:24:05 AM6/7/18
to pyd...@googlegroups.com
Thanks Tom for your explanation, I was quite struggled to find a solution in Pandas which can mimic the subtotal features in Excel...
Reply all
Reply to author
Forward
0 new messages