Detecting seasonality
Assume you want to predict whether a candidate donor will donate next month. As predictive variables, you want to include variables like mean gift, maximum gift and minimum gift last month.
Given is a pandas dataframe gifts
with all the donations made in 2017. Check for seasonality in the gifts, to know whether you should take into account seasonality when constructing the basetable.
Cet exercice fait partie du cours
Intermediate Predictive Analytics in Python
Instructions
- Calculate for each "month" the mean gift made by all donors.
- Calculate for each "month" the number of gifts made by all donors.
- Calclulate for each "month" the median of gifts made by all donors.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Calculate the mean amount donated per month
mean_per_month = gifts.____("month")["amount"].____().reset_index()
print(mean_per_month)
# Calculate the number of donations per month
number_per_month = ____.____("month").____().reset_index()
print(number_per_month)
# Calculate the median amount donated per month
median_per_month = ____.____("____")["____"].____().reset_index()
print(median_per_month)