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.
Deze oefening maakt deel uit van de cursus
Intermediate Predictive Analytics in Python
Oefeninstructies
- 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.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# 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)