Complete the code to create a pivot table that sums the 'Sales' for each 'Region'.
pivot_table = df.pivot_table(index='Region', values='Sales', aggfunc=[1])
The aggfunc='sum' tells pandas to add up the sales values for each region.
Complete the code to create a pivot table that calculates the average 'Sales' for each 'Product'.
pivot_table = df.pivot_table(index='Product', values='Sales', aggfunc=[1])
The aggfunc='mean' calculates the average sales per product.
Fix the error in the code to count the number of sales entries per 'Region'.
pivot_table = df.pivot_table(index='Region', values='Sales', aggfunc=[1])
The aggfunc='count' counts how many sales entries exist per region.
Fill both blanks to create a pivot table that shows the maximum 'Sales' for each 'Region' and 'Product'.
pivot_table = df.pivot_table(index=[1], columns=[2], values='Sales', aggfunc='max')
The index is set to 'Region' to group rows by region, and columns is set to 'Product' to create columns for each product.
Fill all three blanks to create a pivot table that calculates the mean 'Sales' for each 'Region' and 'Product', and fills missing values with 0.
pivot_table = df.pivot_table(index=[1], columns=[2], values=[3], aggfunc='mean').fillna(0)
The pivot table groups rows by 'Region', columns by 'Product', calculates the average 'Sales', and replaces missing values with 0.