Skip to content

DOC: More subtotals / margins in pivot_table #4817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hayd opened this issue Sep 11, 2013 · 9 comments · Fixed by #42922
Closed

DOC: More subtotals / margins in pivot_table #4817

hayd opened this issue Sep 11, 2013 · 9 comments · Fixed by #42922
Assignees
Labels
Docs good first issue Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@hayd
Copy link
Contributor

hayd commented Sep 11, 2013

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

@petehuang
Copy link
Contributor

petehuang commented Dec 27, 2016

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

@jreback
Copy link
Contributor

jreback commented Dec 29, 2016

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

@jreback jreback added Docs and removed Enhancement labels Dec 29, 2016
@jreback jreback modified the milestones: Next Major Release, Someday Dec 29, 2016
@jreback jreback changed the title More subtotals / margins in pivot_table DOC: More subtotals / margins in pivot_table Dec 29, 2016
@Dr-Irv
Copy link
Contributor

Dr-Irv commented May 17, 2017

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.

@chessplayer60
Copy link

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.

@dharmen001
Copy link

#3149 is it resolved??

@lawriewelsby
Copy link

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

@datapythonista datapythonista modified the milestones: Contributions Welcome, Someday Jul 8, 2018
@claytonfaria
Copy link

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

@jxb4892
Copy link
Contributor

jxb4892 commented Jul 30, 2021

Hi, I would like to work on this issue if available. Please let me know!

@Dr-Irv
Copy link
Contributor

Dr-Irv commented Jul 30, 2021

@jxb4892 I've assigned you, so now you own it. If you decide to not continue, let us know so we can remove the assignment

@jreback jreback modified the milestones: Someday, 1.4 Aug 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs good first issue Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging a pull request may close this issue.