ComenzarEmpieza gratis

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.

Este ejercicio forma parte del curso

Intermediate Predictive Analytics in Python

Ver curso

Instrucciones del ejercicio

  • 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.

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

# 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)
Editar y ejecutar código