Skip to content

DOC: More subtotals / margins in pivot_table #42922

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

Merged
merged 2 commits into from
Aug 12, 2021

Conversation

jxb4892
Copy link
Contributor

@jxb4892 jxb4892 commented Aug 6, 2021

Added an example in the documentation for DataFrame.pivot_table to show how to display a pivot table as having a multi-level index, simulating Excel's pivot table with MI and partial group aggregates.

@jreback jreback added this to the 1.4 milestone Aug 8, 2021
@jreback jreback added Docs Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Aug 8, 2021

.. ipython:: python

table = df.pivot_table(index=["A", "B"], columns="C", margins=True, aggfunc=np.sum)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you just make the assignment on L479 and show table there (and then just table.stack() here) rather than repeating

@jxb4892 jxb4892 requested a review from jreback August 11, 2021 23:14
@jreback jreback merged commit ab5322c into pandas-dev:master Aug 12, 2021
@jreback
Copy link
Contributor

jreback commented Aug 12, 2021

thanks @jxb4892

feefladder pushed a commit to feefladder/pandas that referenced this pull request Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: More subtotals / margins in pivot_table
3 participants