pandas/pivot

Pivot Table

Create a pivot table from DataFrame

pandas
pivot
aggregation

Command

pd.pivot_table

Explanation

pd.pivot_table() is used to create spreadsheet-style pivot tables.

Examples

Pivot table with mean aggregation

pd.pivot_table(df, values="col1", index="col2", aggfunc="mean")