Streamlit Data Dashboard
Pure-Python data app: upload a CSV or explore sample data with Plotly charts and metrics.
7 steps
Shown with defaults: npm, pip, Node LTS, Python 3.12 and the template's default add-ons.
1. Check Python 3.12
runtimeMake sure Python 3 is installed. Python 3.12 is recommended for this stack.
bashpython3 --version- Expected result
- Prints Python 3.x.
- Verify
- python3 -c "import sys; assert sys.version_info >= (3, 9); print(sys.version)"
- OS notes
- Install from python.org, `brew install python@3.12` (macOS), `sudo apt install python3 python3-venv` (Debian/Ubuntu), or `pyenv install 3.12`. On Windows the `py` launcher comes with the python.org installer.
2. Create the project folder
templateCreate an empty folder for the project and move into it. All following commands run inside it.
bashmkdir nvx-datacd nvx-data- Expected result
- You are inside ./nvx-data
- Verify
- pwd
3. Create and activate a virtual environment
templateA virtual environment (.venv) keeps this project's Python packages isolated from the system Python.
bashpython3 -m venv .venvsource .venv/bin/activate- Expected result
- Your prompt shows (.venv) and `python` points inside .venv.
- Verify
- python -c "import sys; print(sys.prefix)"
- OS notes
- Debian/Ubuntu may need: sudo apt install python3-venv. On Windows, if activation is blocked run: Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
4. Install Streamlit, pandas and Plotly
templateStreamlit turns Python scripts into web apps; pandas and Plotly handle data and charts.
bashpython -m pip install streamlit pandas plotly- Expected result
- `streamlit version` prints a version.
- Verify
- streamlit version
5. Pin dependencies in requirements.txt
templateFreeze the exact installed versions so teammates, CI and Docker install the same packages.
bashpython -m pip freeze > requirements.txt- Expected result
- requirements.txt lists pinned packages (name==version).
- Verify
- cat requirements.txt
6. Write app.py
templateSidebar controls, metrics, a line chart and a data table — re-runs on every interaction.
Files written by this step: app.py
app.pyimport numpy as np import pandas as pd import plotly.express as px import streamlit as st st.set_page_config(page_title="nvx-data", layout="wide") st.title("nvx-data - data dashboard") uploaded = st.sidebar.file_uploader("Upload a CSV (optional)", type="csv") days = st.sidebar.slider("Days of sample data", 7, 90, 30) if uploaded is not None: df = pd.read_csv(uploaded) st.subheader("Your data") st.dataframe(df) numeric = df.select_dtypes("number").columns.tolist() if numeric: column = st.selectbox("Column to chart", numeric) st.plotly_chart(px.histogram(df, x=column)) else: rng = np.random.default_rng(42) df = pd.DataFrame({ "day": pd.date_range("2026-01-01", periods=days), "signups": rng.integers(20, 120, days), }) df["total"] = df["signups"].cumsum() left, right = st.columns(2) left.metric("Total signups", int(df["total"].iloc[-1])) right.metric("Average per day", round(float(df["signups"].mean()), 1)) st.plotly_chart(px.line(df, x="day", y="total", title="Cumulative signups")) st.dataframe(df)- Expected result
- app.py exists.
- Verify
- python -m py_compile app.py
7. Run the dashboard
templaterun manually · dev serverStarts a local server and opens the browser.
bashstreamlit run app.py- Expected result
- http://localhost:8501 shows the dashboard.
- Verify
- curl -I http://localhost:8501