ComenzarEmpieza gratis

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.

Este ejercicio forma parte del curso

Customer Segmentation in Python

Ver curso

Instrucciones del ejercicio

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

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# 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)
Editar y ejecutar código