Get startedGet started for free

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.

This exercise is part of the course

Intermediate Predictive Analytics in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample 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"]
Edit and Run Code