Skip to content

Commit ab5322c

Browse files
authored
DOC: More subtotals / margins in pivot_table (#42922)
1 parent 860ff03 commit ab5322c

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)