Bank Marketing Dashboard
Business Question
The entire dashboard is built around this question:
“Which customers are more likely to subscribe to the bank's term-deposit campaign, and what campaign/customer factors influence conversion?”
End-to-End Pipeline
bank_market.csv → Pandas → Data Cleaning → Feature Engineering → Business KPIs → Plotly Charts → Dash Layout → Filters → Callbacks → Interactive Dashboard
Load and Explore the Data
import numpy as np
import pandas as pd
from dash import Dash, Input, Output, dcc, html, callback
import plotly.express as px
import plotly.graph_objects as go
df = pd.read_csv("bank_market.csv")
print(df.head())
print(df.shape) # (45211, 18)
print(df.info())
print(df.isnull().sum())
Data Cleaning
We clean column names and make all text values consistent (lowercase + strip spaces).
# Remove spaces from column names
df.columns = df.columns.str.strip()
# Clean all text columns
for col in df.select_dtypes(include="object").columns:
df[col] = df[col].astype(str).str.strip().str.lower()
"Manager", "manager", " MANAGER " would be treated as different categories.
Create the Target Variable
y is the business outcome:
y == "yes"→ Customer subscribedy == "no"→ Customer did not subscribe
df["subscribed"] = df["y"].map({"yes": 1, "no": 0})
print(df["subscribed"].value_counts())
# 0 → 39922
# 1 → 5289
conversion_rate = df["subscribed"].mean() * 100
print(conversion_rate) # ≈ 11.70%
Feature Engineering – Age Group
df["age_group"] = pd.cut(
df["age"],
bins=[0, 30, 40, 50, 60, np.inf],
labels=["under 30", "30-39", "40-49", "50-59", "60+"],
right=False
)
print(df["age_group"].value_counts())
Dashboard Layout Structure
The layout contains:
- Title
- Filters (Job, Marital Status, Education, Subscription, Age Range)
- Reset Button
- KPI Cards (Total Customers, Avg Age, Avg Balance, Subscribers, Subscription Rate)
- Six interactive charts
Main Dashboard Callback
This single callback updates all KPIs and all charts whenever any filter changes.
@callback(
# KPI Outputs
Output("Total_customers", "children"),
Output("average_age", "children"),
Output("average_balance", "children"),
Output("Subscriber-count", "children"),
Output("Subscription-rate", "children"),
# Chart Outputs
Output("age-chart", "figure"),
Output("job-chart", "figure"),
Output("subscription-chart", "figure"),
Output("marital-chart", "figure"),
Output("balance-chart", "figure"),
Output("education-chart", "figure"),
# Inputs (filters)
Input("job-filter", "value"),
Input("marital-filter", "value"),
Input("education-filter", "value"),
Input("subscription-filter", "value"),
Input("age-filter", "value")
)
def update_dashboard(selected_job, selected_marital,
selected_education, selected_subscription,
selected_age):
filtered_df = df.copy()
# Apply filters
if selected_job:
filtered_df = filtered_df[filtered_df["job"] == selected_job]
if selected_marital:
filtered_df = filtered_df[filtered_df["marital"] == selected_marital]
if selected_education:
filtered_df = filtered_df[filtered_df["education"] == selected_education]
if selected_subscription != "all":
filtered_df = filtered_df[filtered_df["y"] == selected_subscription]
min_age, max_age = selected_age
filtered_df = filtered_df[filtered_df["age"].between(min_age, max_age)]
# KPI calculations
total_customers = len(filtered_df)
average_age = round(filtered_df["age"].mean(), 1) if total_customers > 0 else 0
average_balance = round(filtered_df["balance"].mean(), 2) if total_customers > 0 else 0
subscriber_count = len(filtered_df[filtered_df["y"] == "yes"])
subscription_rate = (subscriber_count / total_customers * 100) if total_customers > 0 else 0
# Create charts (age histogram, job bar, subscription pie, etc.)
# ...
return (
f"{total_customers:,}",
f"{average_age}",
f"${average_balance:,.0f}",
f"{subscriber_count:,}",
f"{subscription_rate:.1f}%",
age_fig, job_fig, subscription_fig,
marital_fig, balance_fig, education_fig
)
Reset Filters Callback
@callback(
Output("job-filter", "value"),
Output("marital-filter", "value"),
Output("education-filter", "value"),
Output("subscription-filter", "value"),
Output("age-filter", "value"),
Input("reset-button", "n_clicks")
)
def reset_filters(n_clicks):
return (None, None, None, "all", [minimum_age, maximum_age])
How to Run the Dashboard
if __name__ == "__main__":
app.run(debug=True, port=8051)
http://127.0.0.1:8051) to use the interactive dashboard.
Dashboard Output Preview
When the dashboard runs successfully you will see the following components:
• 5 KPI cards at the top that update instantly when filters change
• Age histogram, Job bar chart, Subscription donut, Marital status bar, Age vs Balance scatter, Education vs Subscription grouped bar
• Interactive filters (Job, Marital, Education, Subscription, Age Range) + Reset button
• All charts and KPIs refresh together through a single callback
• Fixed typo
maximu_age → maximum_age• Ensured all component IDs are consistent
• Added missing
callback import• Cleaned column name handling
Bank Marketing Dashboard
Complete end-to-end interactive dashboard built with Pandas + Plotly + Dash.
Select any topic from the left sidebar to begin.
Start Learning →
