â The Goal (Question)
Build a multi-functional analytics dashboard that enables teachers to:- Upload a student grades CSV file (
students.csv). - Track dashboard opens/visits in the sidebar using Session State.
- Dynamically filter the dataset by Department, Subject, and Search Name using a sidebar form.
- Organize content cleanly into three tabs: Dataset, Reports (KPI metrics), and Charts (visualizations using Matplotlib).
- Download the filtered report as a new CSV file.
đ Implementation Plan
- Setup: Initialize the project directory and install dependencies using
uv(streamlit,pandas,matplotlib). - State & Sidebar: Initialize session state to track page visits and build the filters sidebar.
- Data Loading: Implement a CSV file uploader to load the grades dataset.
- Data Filtering: Filter the dataframe based on the userâs form inputs.
- Layout & Tabs: Organize the dashboard main panel into three switchable tabs:
- Dataset Tab: Shows the raw filtered data table.
- Reports Tab: Displays key performance indicators (KPIs) like student count, highest/lowest/average marks.
- Charts Tab: Renders average marks by department and grade distribution charts.
- Actions & Feedback: Add a download button to export the filtered dataset and include progress spinners.
đ ī¸ Step-by-Step Implementation
Step 1: Project Setup
Create a new directory for your project and add the following structure:uv:
Step 2: Initialize App & Session State
Openapp.py and set up the page config, title, and session state page-visit counter:
Step 3: Handle CSV File Upload
Below the visit counter, implement the file uploader and load the data:Step 4: Construct the Filter Form
Create input widgets inside a form inside the sidebar to gather filtering options:Step 5: Apply Filters & Display Row Metrics
Filter the dataframe according to the selected parameters and display basic metadata:Step 6: Create the Tabbed Layout
Organize your content by adding three tabs to the main panel:Step 7: Build the Reports Tab (KPIs)
Implement detailed KPI calculations inside the second tab:Step 8: Build the Charts Tab (Visualizations)
Generate and render the Matplotlib graphs in the third tab:Step 9: Add Download Button & Status Feedback
Provide a download option at the bottom of the page and trigger a loading spinner:đ Sample Dataset (students.csv)
Save this data as students.csv in your project folder to test the dashboard: