EDA Project 2 — Banking/Customer Churn Dataset
A real analyst problem: which customers are leaving, and why? Full EDA on a banking customer-churn dataset to find the factors driving churn.
Learning Objectives
- Define customer churn and calculate the churn rate.
- Apply the EDA workflow to a banking churn dataset.
- Compare churn across segments (geography, gender, age, balance).
- Use boxplots and heatmaps to find factors associated with churn.
- Translate the analysis into business recommendations.
1. The Business Problem
A bank wants to reduce customer churn — customers closing accounts and leaving. Your job as the analyst: figure out who churns and what drives it, so the business can act.
2. The Dataset
The generic banking churn dataset has these columns:
| Column | Meaning |
|---|---|
customer_id | unique identifier |
credit_score | credit score |
geography | country/region |
gender | male / female |
age | age in years |
tenure | years with the bank |
balance | account balance |
num_products | number of products held |
is_active_member | 1 = active, 0 = not |
exited | 1 = churned, 0 = stayed |
3. The EDA — Step by Step
Step 1 — Load & inspect
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.read_csv("bank_churn.csv")
df.shape # (rows, columns)
df.head()
df.info() # dtypes and non-null counts
Step 2 — Check missing values & duplicates
df.isnull().sum() # missing per column
df = df.drop_duplicates() # remove duplicates
Step 3 — Overall churn rate
churn_rate = df["exited"].mean() * 100
print(f"Overall churn rate: {churn_rate:.2f}%")
Step 4 — Churn rate by segment
# Churn by geography
df.groupby("geography")["exited"].mean()
# Churn by gender
df.groupby("gender")["exited"].mean()
# Churn by number of products
df.groupby("num_products")["exited"].mean()
Step 5 — Visualize (univariate & bivariate)
# Who churns? (countplot)
sns.countplot(x="exited", data=df)
# Age distribution: churned vs stayed
sns.boxplot(x="exited", y="age", data=df)
# Balance distribution: churned vs stayed
sns.boxplot(x="exited", y="balance", data=df)
# Correlation heatmap
sns.heatmap(df.corr(numeric_only=True), annot=True)
Step 6 — Insights & recommendations
Write 3–5 findings, e.g. "Older customers churn at a higher rate; customers with only one product are most likely to leave; inactive members churn far more than active ones — so target single-product, inactive, older segments with retention offers."
4. Interview Questions (with Model Answers)
Churn/EDA project questions are the classic "tell me about a project" prompt. Self-test before revealing.
IQ1. Walk me through your churn analysis project.
Model answer: "I loaded a banking churn dataset, checked for missing values and duplicates, computed the overall churn rate, then broke it down by geography, gender, age, and product count. I used boxplots and a heatmap to find the drivers, then wrote recommendations."
IQ2. What is churn rate, and how do you calculate it?
Model answer: "Churn rate is the percentage of customers who left in a period. I calculate it as
(number who churned ÷ total customers) × 100. In Pandas, that's df['exited'].mean() * 100."
IQ3. What factors did you find associated with churn?
Model answer: "Typically older customers, customers with fewer products, and inactive members
churn more. I found these by comparing churn rate across segments with groupby and boxplots."
IQ4. How do you compare churn across two groups (e.g., gender)?
Model answer: "With df.groupby('gender')['exited'].mean() — since exited is 0/1, the
mean is the churn rate per group. I'd also visualize it with a countplot or boxplot."
IQ5. Why use a boxplot for churn analysis?
Model answer: "A boxplot shows the distribution of a numeric variable (like age or balance) for each churn group side by side, and highlights outliers — so I can see whether churned customers differ."
IQ6. What's the difference between churn rate and customer count?
Model answer: "Customer count is a raw number; churn rate is a proportion (churned ÷ total), so it lets me compare churn across segments of different sizes fairly."
IQ7. What insights would you give the business from this EDA?
Model answer: "I'd point out which segments churn most and recommend targeted retention — for example, offers for single-product or inactive customers, and onboarding that encourages customers to hold multiple products."
IQ8. How do you check for missing values and outliers in a churn dataset?
Model answer: "Missing values with isnull().sum(); outliers with describe()
and boxplots — points far outside the whiskers. I'd decide whether to drop, fill, or cap them based on context."
IQ9. What would you recommend to reduce churn, based on your analysis?
Model answer: "I'd recommend targeting the highest-churn segments with retention campaigns — re-engaging inactive members, cross-selling a second product to single-product customers, and proactively contacting high-risk older customers."
Key Takeaways
Churn rate = (churned ÷ total) × 100 — a proportion, not a raw count.
groupby(...)["exited"].mean() gives churn rate per segment.
Boxplots compare a numeric variable across churned vs stayed.
The goal of churn EDA is actionable segments, not just charts.
You now have two portfolio EDA projects — a strong resume signal.
Objective Questions — Test Your Understanding
Q1. In a churn dataset, what does exited = 1 typically mean?
Q2. How do you calculate the overall churn rate?
Q3. Which plot compares a numeric variable (like age) across two groups (churned vs stayed)?
Q4. Which Pandas expression gives the churn rate per geography?
Q5. What is the FIRST step in this EDA project?