Pandas: DOC: More subtotals / margins in pivot_table

Created on 11 Sep 2013  路  7Comments  路  Source: pandas-dev/pandas

Perhaps there should be some argument to pivot_table to include subtotals of MI columns and rows, i.e. not just margins.

http://stackoverflow.com/questions/15570099/pandas-pivot-tables-row-subtotals

Docs Reshaping good first issue

Most helpful comment

I'm a data analyst trying to move away from Excel and this would be a very useful feature to have when pivoting.

All 7 comments

Hi,

This issue hasn't been touched for a few years. Does this continue to represent a useful enhancement?

For clarity: MI is referring to MultiIndex

Related: #3149

let's repurpose this to an example in the reshape.rst (or in the cookbook.rst). want to do a PR?

There is a related issue, in that if you just use margins = True, without specifying aggfunc, the margin values are the means, not the sums. I think this just needs to be mentioned in the docs.

Actually, the way I understand it is a bit different. When we speak about analysing data, there is often a so called "drill-down" involved, which will naturally result in an MI. But then, I actually want intermediate aggregates as well as shown in the following picture, e.g.:
bild18-extpivtab_rollup
Now in pandas, all I could get is the full margins ("Gesamt Ergebnis" in the picture) but not the intermediate one for the higher levels.
I, for one, would be very interested in being able to show those intermediate sums in a pivot table (which, technically, would be "rolled up" values). It would seem to me that #3149 is just about that.

3149 is it resolved??

I'm a data analyst trying to move away from Excel and this would be a very useful feature to have when pivoting.

Hello, I came across this problem too. I started to learn python and pandas so that I can replace Excel, however still trying to figure out the pivot tables subtotal with MI.
any chance of considering this feature in a near future? thank you for the great work with pandas

Was this page helpful?
0 / 5 - 0 ratings