/customer personality.py Secret
Created
February 8, 2021 09:52
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Create Age segment | |
cut_labels_Age = ['Young', 'Adult', 'Mature', 'Senior'] | |
cut_bins = [0, 30, 45, 65, 120] | |
data['Age_group'] = pd.cut(data['Age'], bins=cut_bins, labels=cut_labels_Age) | |
#Create Income segment | |
cut_labels_Income = ['Low income', 'Low to medium income', 'Medium to high income', 'High income'] | |
data['Income_group'] = pd.qcut(data['Income'], q=4, labels=cut_labels_Income) | |
#Create Seniority segment | |
cut_labels_Seniority = ['New customers', 'Discovering customers', 'Experienced customers', 'Old customers'] | |
data['Seniority_group'] = pd.qcut(data['Seniority'], q=4, labels=cut_labels_Seniority) | |
data=data.drop(columns=['Age','Income','Seniority']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment