BaşlayınÜcretsiz Başlayın

Calculate 3 groups for recency and frequency

You will now group the customers into three separate groups based on Recency, and Frequency.

The dataset has been loaded as datamart, you can use console to view top rows of it. Also, pandas has been loaded as pd.

We will use the result from the exercise in the next one, where you will group customers based on the MonetaryValue and finally calculate and RFM_Score.

Once completed, print the results to the screen to make sure you have successfully created the quartile columns.

Bu egzersiz

Customer Segmentation in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Create labels for Recency with a decreasing range of 3 through 1, and labels for Frequency with an increasing range of 1 through 3.
  • Assign these labels to three equal percentile groups based on Recency.
  • Assign these labels to three equal percentile groups based on Frequency.
  • Create new quantile columns R and F.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Create labels for Recency and Frequency
r_labels = range(____, 0, ____); f_labels = range(1, ____)

# Assign these labels to three equal percentile groups 
r_groups = pd.qcut(datamart['____'], q=____, labels=____)

# Assign these labels to three equal percentile groups 
f_groups = pd.qcut(datamart['____'], q=____, labels=____)

# Create new columns R and F 
datamart = datamart.assign(____=____.values, ____=____.values)
Kodu Düzenle ve Çalıştır