CommencerCommencer gratuitement

Calculating aggregated variables

In the previous exercise you constructed two basetables corresponding with two snapshots, and added the target values to these basetables. In this exercise, you will learn how to add aggregated variables. You will add the sum of donations last month (December 2016 and December 2017 for the respective snapshots) to both basetables.

Cet exercice fait partie du cours

Intermediate Predictive Analytics in Python

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Maximum of donations for each donor in december 2016
gifts_max_december_2016 = gifts_december_2016.____("donor_id")["amount"].____().reset_index()
gifts_max_december_2016.columns = ["donor_id", "max_amount"]

# Maximum of donations for each donor in december 2017
gifts_max_december_2017 = gifts_december_2017.____("donor_id")["amount"].____().reset_index()
gifts_max_december_2017.columns = ["donor_id", "max_amount"]
Modifier et exécuter le code