text_html_output_1.png
import datetime

import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

df = pd.read_excel('/kaggle/input/arketing-campaign/marketing_campaign.xlsx')
df

df.shape

df.isnull().sum()

df.isnull().sum()

df.Year_Birth = pd.to_datetime(df['Year_Birth'], format='%Y')
year_now = datetime.date.today().year
df['Age'] = df['Year_Birth'].apply(lambda x: year_now - x.year)
df.drop('Year_Birth', axis=1, inplace=True)

# Income spending by age
fig,ax = plt.subplots(1,2,figsize=(18,4))
sns.scatterplot(x='Age',y='Income',data=df, hue='Response',ax=ax[0])
sns.boxplot(x='Age',data=df,ax=ax[1])
plt.show()

df['spending'] = df.MntFishProducts + df.MntFruits + df.MntGoldProds + df.MntMeatProducts + df.MntSweetProducts + df.MntWines
df.drop(['MntFishProducts', 'MntFruits', 'MntGoldProds', 'MntMeatProducts', 'MntSweetProducts', 'MntWines'], axis=1, inplace=True)

fig, ax = plt.subplots(1, 2, figsize=(16, 4))
sns.scatterplot(x='Income', y='spending', data=df, hue='Response', ax=ax[0])
sns.histplot(df.spending, ax=ax[1])
plt.show()