Get startedGet started for free

Pivoting on one variable

Pivot tables are the standard way of aggregating data in spreadsheets.

In pandas, pivot tables are essentially another way of performing grouped calculations. That is, the .pivot_table() method is an alternative to .groupby().

In this exercise, you'll perform calculations using .pivot_table() to replicate the calculations you performed in the last lesson using .groupby().

sales is available and pandas is imported as pd.

This exercise is part of the course

Data Manipulation with pandas

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Pivot for mean weekly_sales for each store type
mean_sales_by_type = sales.____

# Print mean_sales_by_type
print(mean_sales_by_type)
Edit and Run Code