DataFrame.pivot_table(values=None, index=None, columns=None, aggfunc='mean', fill_value=None, margins=False, dropna=None, margins_name='All', observed=False, sort=True)[source]#

Create a spreadsheet-style pivot table as a DataFrame.

valuescolumn name or list of column names to aggregate, optional
indexlist of column names

Values to group by in the rows.

columnslist of column names

Values to group by in the columns.

aggfuncstr or dict, default “mean”

If dict is passed, the key is column to aggregate and value is function name.

fill_valuescalar, default None

Value to replace missing values with (in the resulting pivot table, after aggregation).

marginsNot supported
dropnaNot supported
margins_nameNot supported
observedNot supported
sortNot supported

An Excel style pivot table.