-
-
Save amankharwal/d03c6c33302d9b1af79b094570d91210 to your computer and use it in GitHub Desktop.
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