Skip to content

Commit 4faf81a

Browse files
jxb4892feefladder
authored andcommitted
DOC: More subtotals / margins in pivot_table (pandas-dev#42922)
1 parent 88f0f40 commit 4faf81a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

doc/source/user_guide/reshaping.rst

+9-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,15 @@ rows and columns:
474474

475475
.. ipython:: python
476476
477-
df.pivot_table(index=["A", "B"], columns="C", margins=True, aggfunc=np.std)
477+
table = df.pivot_table(index=["A", "B"], columns="C", margins=True, aggfunc=np.std)
478+
table
479+
480+
Additionally, you can call :meth:`DataFrame.stack` to display a pivoted DataFrame
481+
as having a multi-level index:
482+
483+
.. ipython:: python
484+
485+
table.stack()
478486
479487
.. _reshaping.crosstabulations:
480488

0 commit comments

Comments
 (0)