-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
42 lines (33 loc) · 1.09 KB
/
Copy pathapp.py
File metadata and controls
42 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
# App title
st.set_page_config(page_title="Student Data Dashboard", layout="wide")
st.title("Student Data Visualization Dashboard")
# Load data
@st.cache_data
def load_data():
return pd.read_csv("data/students.csv")
df = load_data()
# Sidebar filter
st.sidebar.header("Filters")
department = st.sidebar.selectbox(
"Select Department",
df["Department"].unique()
)
filtered_df = df[df["Department"] == department]
# Display raw data
st.subheader("Dataset Preview")
st.dataframe(filtered_df)
# Line chart
st.subheader("Student Growth Over Years")
fig, ax = plt.subplots()
ax.plot(filtered_df["Year"], filtered_df["Students"], marker="o")
ax.set_xlabel("Year")
ax.set_ylabel("Number of Students")
ax.set_title(f"{department} Department Growth")
st.pyplot(fig)
# Summary stats
st.subheader("Key Insights")
st.write(f"**Total Students (Latest Year):** {filtered_df.iloc[-1]['Students']}")
st.write(f"**Growth Rate:** {filtered_df.iloc[-1]['Students'] - filtered_df.iloc[0]['Students']}")