1. Learn
  2. /
  3. Courses
  4. /
  5. Customer Segmentation in Python

Exercise

Pre-process RFM data

We have loaded the dataset with RFM values you calculated previously as datamart_rfm. Since the variables are skewed and are on different scales, you will now un-skew and normalize them.

The pandas library is loaded as pd, and numpy as np. Take some time to explore the datamart_rfm in the console.

Instructions

100 XP
  • Apply log transformation to unskew the datamart_rfm and store it as datamart_log.
  • Initialize a StandardScaler() instance as scaler and fit it on the datamart_log data.
  • Transform the data by scaling and centering it with scaler.
  • Create a pandas DataFrame from 'datamart_normalized' by adding index and column names from datamart_rfm.