Session Ready
Exercise

Calculate recency deciles (q=4)

We have created a dataset for you with random CustomerID and Recency_Days values as data. You will now use this dataset to group customers into quartiles based on Recency_Days values and assign labels to each of them.

Be cautious about the labels for this exercise. You will see that the labels are inverse, and will required one additional step in separately creating them. If you need to refresh your memory on the process of creating the labels, check out the slides!

The pandas library as been loaded as pd. Feel free to print the data to the console.

Instructions
100 XP
  • Store labels from 4 to 1 in a decreasing order.
  • Create a spend quartile with 4 groups and pass the previously created labels.
  • Assign the quartile values to the Recency_Quartile column in data.
  • Print data with sorted Recency_Days values.