Calculations with .groupby()
The .groupby()
method makes life much easier. In this exercise, you'll perform the same calculations as last time, except you'll use the .groupby()
method. You'll also perform calculations on data grouped by two variables to see if sales differ by store type depending on if it's a holiday week or not.
sales
is available and pandas
is loaded as pd
.
This exercise is part of the course
Data Manipulation with pandas
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Group by type; calc total weekly sales
sales_by_type = ____.____("____")["____"].____()
# Get proportion for each type
sales_propn_by_type = ____ / sum(____)
print(sales_propn_by_type)