Skip to content

Commit ee352b1

Browse files
DOC: Fixed documentation for pivot_table margins (#48916) (#48965)
* DOC: Fixed documentation for pivot_table margins (#48916) The documentation for the margins parameter of pivot_table was incorrect. It said that the parameter added rows and columns, but it actually passed them to aggfunc. I used the documentation from the user guide to replace the old documentation, as well as added a sentence to the documentation for aggfunc that explained its role in calculating margins. * Update pandas/core/frame.py Co-authored-by: Matthew Roeschke <[email protected]> Co-authored-by: Matthew Roeschke <[email protected]>
1 parent e4dd35f commit ee352b1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pandas/core/frame.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -8604,12 +8604,15 @@ def pivot(
86048604
hierarchical columns whose top level are the function names
86058605
(inferred from the function objects themselves)
86068606
If dict is passed, the key is column to aggregate and value
8607-
is function or list of functions.
8607+
is function or list of functions. If ``margin=True``,
8608+
aggfunc will be used to calculate the partial aggregates.
86088609
fill_value : scalar, default None
86098610
Value to replace missing values with (in the resulting pivot table,
86108611
after aggregation).
86118612
margins : bool, default False
8612-
Add all row / columns (e.g. for subtotal / grand totals).
8613+
If ``margins=True``, special ``All`` columns and rows
8614+
will be added with partial group aggregates across the categories
8615+
on the rows and columns.
86138616
dropna : bool, default True
86148617
Do not include columns whose entries are all NaN. If True,
86158618
rows with a NaN value in any column will be omitted before

0 commit comments

Comments
 (0)