Courses Curriculum Cities Blog Enroll Now
Dashboards with Dash and Streamlit · Day 4 of 5 ~45 minutes

Day 4: Dashboards with Dash and Streamlit

Charts in files are hard to share. Dashboards are charts on a live URL anyone can visit. Learn two approaches: Dash for full control, Streamlit for speed.

1
Day 1
2
Day 2
3
Day 3
4
Day 4
5
Day 5
What You'll Build

A working data dashboard with filters, charts, and a KPI summary panel — deployed locally and ready to share via a public URL.

1
Section 1 · 10 min

Streamlit: Dashboard in 30 Lines

bash
$ pip install streamlit plotly pandas
pythondashboard.py
import streamlit as st
import plotly.express as px
import pandas as pd

st.title("Sales Dashboard")

# KPI metrics in columns
col1, col2, col3 = st.columns(3)
col1.metric("Total Revenue", "$342,000", "+12%")
col2.metric("New Customers", "148", "+8")
col3.metric("Avg Deal Size", "$2,310", "-3%")

# Filter
df = px.data.gapminder()
continent = st.selectbox("Continent", df["continent"].unique())
filtered = df[df["continent"] == continent]

# Chart updates automatically when filter changes
fig = px.line(filtered, x="year", y="lifeExp",
                   color="country", title=f"{continent}: Life Expectancy")
st.plotly_chart(fig, use_container_width=True)

Run with: streamlit run dashboard.py. Opens in your browser instantly. The selectbox automatically reruns the whole script when you change the value — that's Streamlit's magic.

2
Section 2 · 15 min

Adding More Streamlit Components

Streamlit has a rich component library for interactive dashboards:

pythoncomponents.py
import streamlit as st
import pandas as pd

# Sidebar filters
with st.sidebar:
    st.header("Filters")
    year_range = st.slider("Year Range", 2020, 2025, (2022, 2025))
    show_table = st.checkbox("Show raw data")

# File upload
uploaded = st.file_uploader("Upload CSV", type=["csv"])
if uploaded:
    df = pd.read_csv(uploaded)
    st.success(ff"Loaded {len(df)} rows")
    if show_table:
        st.dataframe(df)
3
Section 3 · 20 min

Deploy Your Dashboard

Streamlit has free hosting at streamlit.io/cloud. Push your app to GitHub, connect the repo, done.

1

Push your dashboard.py and requirements.txt to a GitHub repo.

2

Go to share.streamlit.io → "Deploy an app" → connect your GitHub repo.

3

Select your main file (dashboard.py), click Deploy. Your app gets a public URL in about 2 minutes.

Free tier limits: Streamlit Cloud's free tier is generous — 1 app per account with no usage limits for public apps. For multiple apps or private apps, upgrade. For serious production use, deploy to Railway or similar.

What You Learned Today

  • How Streamlit's reactive execution model works: every user interaction reruns the script
  • st.metric for KPIs, st.selectbox/slider/checkbox for filters, st.sidebar for layout
  • How to handle file uploads and dynamically generated charts
  • The one-click deployment process with Streamlit Cloud
Your Challenge

Go Further on Your Own

  • Build a dashboard for a real dataset you use at work. Add at least 2 filters and 3 charts.
  • Add a 'Download as CSV' button to your dashboard using st.download_button()
  • Build a comparison view: show the same metric for two time periods side by side using st.columns()
Day 4 Complete

Nice work. Keep going.

Day 5 is ready when you are.

Continue to Day 5
Course Progress
80%

Want live instruction and hands-on projects? Join the AI bootcamp — 3 days, 5 cities.

Finished this lesson?