ComeçarComece de graça

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 exercício faz parte do curso

Intermediate Predictive Analytics in Python

Ver curso

Instruções do exercício

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

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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 e executar o código