Complete the code to group the DataFrame by 'Category'.
grouped = df.[1]('Category')
The groupby method groups data by a column, which is needed here.
Complete the code to calculate the mean of each group.
result = df.groupby('Category').[1]()
The mean() function calculates the average for each group.
Fix the error in the code to chain groupby and mean using pipe.
result = df.[1](lambda x: x.groupby('Category').mean())
The pipe method allows chaining custom functions like grouping and averaging.
Fill both blanks to create a dictionary of group sizes for groups with size greater than 2.
sizes = df.groupby('Category').[1]().to_dict() filtered = {k: v for k, v in sizes.items() if v [2] 2}
size() gives group sizes, and filtering with > keeps groups larger than 2.
Fill all three blanks to create a DataFrame with mean sales per category, reset index, and rename the column to 'Average Sales'.
result = (df.groupby([1]).[2]().reset_index().rename(columns=[3]))
Group by 'Category', calculate mean, then rename 'Sales' column to 'Average Sales'.
