text_plain_output_1.png
import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import plotly.express as px

data = '../input/bank-customer-churn-dataset/Bank Customer Churn Prediction.csv'

df = pd.read_csv(data)

df.shape

df.describe

df.dtypes

features = df.keys()
features = features.drop('churn')
subsets = ['credit_score']
df.groupby('churn')[features].mean().style.background_gradient(cmap='ocean')

fig = px.histogram(df, x="age", y="balance", color="churn",
                   marginal="box",
                   hover_data=df.columns)
fig.show()

sizes = [df.churn[df['churn']==1].count(), df.churn[df['churn']==0].count()]
labels = ['Churned', 'Not Churned']
figure, axes = plt.subplots(figsize=(10, 8))
axes.pie(sizes, labels=labels,shadow=True,autopct = '%1.2f%%')
plt.legend()
plt.title("Churned VS Not Churned", size = 15)
plt.show()

churned_french = df.churn[(df.country == 'France') & (df.churn == 1)].count()
count_french = df.churn[df.country == 'France'].count()
churned_german = df.churn[(df.country == 'Germany') & (df.churn == 1)].count()
count_german = df.churn[df.country == 'Germany'].count()
churned_spain = df.churn[(df.country == 'Spain') & (df.churn == 1)].count()
count_spain = df.churn[df.country == 'Spain'].count()

px.histogram(df, x='country', color='churn', barmode='group')