Study interactive :: Progress tools open in the Study Hub reader.

Project 6: Customer Data Dashboard with Streamlit

Build an interactive dashboard to visualize and analyze customer data using Streamlit.

Difficulty

Beginner

Time Estimate

2-3 days

Skills You'll Practice

Learning Objectives

By completing this project, you will learn to:

Prerequisites

Before starting, you should have completed:

Dataset

Option 1: E-commerce Customer Dataset

Option 2: Customer Churn Dataset

Option 3: Create Your Own

Project Steps

Step 1: Setup and Data Loading

Step 2: Basic Dashboard Structure

Step 3: Data Overview Section

Step 4: Interactive Visualizations

Step 5: Analysis Sections

Step 6: Advanced Features

Step 7: Deployment (Optional)

Code Structure

project-06-customer-dashboard/
├── README.md
├── app.py                    # Main Streamlit application
├── data/
│   └── customer_data.csv     # Dataset
├── notebooks/
│   └── data_exploration.ipynb
├── requirements.txt
└── .streamlit/
    └── config.toml           # Streamlit configuration

Example Code Skeleton

import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

# Page configuration
st.set_page_config(
    page_title="Customer Dashboard",
    layout="wide"
)

# Load data
@st.cache_data
def load_data():
    df = pd.read_csv('data/customer_data.csv')
    return df

df = load_data()

# Sidebar
st.sidebar.title("Filters")
# Add filters here

# Main content
st.title("Customer Data Dashboard")
st.markdown("Interactive dashboard for customer analysis")

# Overview section
st.header("Data Overview")
col1, col2, col3, col4 = st.columns(4)
col1.metric("Total Customers", len(df))
col2.metric("Total Revenue", f"${df['revenue'].sum():,.0f}")
# Add more metrics

# Visualizations
st.header("Customer Analysis")
# Add charts here

# Run with: streamlit run app.py

Key Streamlit Components to Use

Extensions

  1. Add Machine Learning Predictions

    • Integrate a simple classification model
    • Show predictions in the dashboard
    • Add model performance metrics
  2. Real-time Data Updates

    • Connect to a database
    • Auto-refresh functionality
    • Live data updates
  3. Multi-page Dashboard

    • Use st.sidebar for navigation
    • Create separate pages for different analyses
    • Use st.session_state for state management
  4. Advanced Visualizations

    • Interactive Plotly charts
    • Maps with st.map() or folium
    • 3D visualizations
  5. Export Functionality

    • Download filtered data as CSV
    • Export charts as images
    • Generate PDF reports

Evaluation Criteria

Your dashboard should:

Resources

Tips for Success

  1. Start Simple: Begin with basic visualizations, then add interactivity
  2. Use Caching: Use @st.cache_data for data loading to improve performance
  3. Organize Well: Use columns and containers for better layout
  4. Test Interactively: Run streamlit run app.py and test as you build
  5. Keep It Fast: Optimize data loading and processing
  6. Make It Beautiful: Use Streamlit's built-in styling options

Next Steps

After completing this project:


Ready to build? Start by setting up your environment and loading your dataset!