text_plain_output_1.png
from datetime import date

import pandas as pd

customer_data = pd.read_csv('../input/customer-personality-analysis/marketing_campaign.csv', sep='\t', index_col='ID')

customer_data.shape

customer_data.isnull().sum()

customer_data_cleaned = customer_data.dropna()

from datetime import date
def get_age(birthyear):
    return date.today().year - birthyear
ages = customer_data_cleaned.Year_Birth.map(get_age)
customer_data_cleaned['Age'] = customer_data_cleaned.Year_Birth.map(get_age)

customer_data_cleaned.sort_values(by='Year_Birth').head()

customer_data_cleaned.drop([11004, 1150, 7829], inplace=True)

customer_data_cleaned['Spending'] = customer_data_cleaned.MntWines + customer_data_cleaned.MntFruits + customer_data_cleaned.MntMeatProducts + customer_data_cleaned.MntFishProducts + customer_data_cleaned.MntSweetProducts + customer_data_cleaned.MntGoldProds
customer_data_cleaned['Time_With_Company'] = pd.to_datetime(customer_data_cleaned.Dt_Customer, dayfirst=True, format='%d-%m-%Y')
customer_data_cleaned['Time_With_Company'] = pd.to_numeric(customer_data_cleaned.Time_With_Company.dt.date.apply(lambda z: date.today() - z).dt.days, downcast='integer') / 30

customer_data_cleaned.Education.unique()