-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.py
More file actions
145 lines (107 loc) · 3.45 KB
/
Student.py
File metadata and controls
145 lines (107 loc) · 3.45 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import streamlit as st
import pandas as pd
from streamlit_option_menu import option_menu
# for emoji you can use https://getemoji.com/
st.set_page_config(page_title="Student Result Analysis", layout="wide")
st.title("🎓 Student Result Analysis System")
with st.sidebar:
st.header("📂 Upload Dataset")
uploaded_file = st.file_uploader("Upload CSV File", type=["csv"])
st.markdown("---")
selected = option_menu(
menu_title="📌 Menu",
options=[
"Raw Data",
"Student Result",
"Topper",
"Search Student",
"Subject Analysis",
"Pass / Fail",
"Pivot Table"
],
icons=[
"table",
"bar-chart",
"trophy",
"search",
"book",
"check-circle",
"grid"
],
menu_icon="menu-button-wide",
default_index=0
)
if uploaded_file is None:
st.warning("Please upload a CSV file to continue.")
st.stop()
df = pd.read_csv(uploaded_file)
if selected == "Raw Data":
st.subheader("📊 Raw Data")
st.dataframe(df)
elif selected == "Student Result":
total = df.groupby("Name")["Marks"].sum()
avg = df.groupby("Name")["Marks"].mean()
result = pd.DataFrame({
"Total": total,
"Average": avg
}).reset_index()
st.dataframe(
result,
use_container_width=True,
column_config={
"Name": st.column_config.TextColumn("Student Name", width="medium"),
"Total": st.column_config.NumberColumn("Total Marks", width="small"),
"Average": st.column_config.NumberColumn("Average Marks", width="small")
}
)
# result = pd.DataFrame({
# "Total": total,
# "Average": avg
# })
# st.subheader("📈 Student Performance Summary")
# st.dataframe(result)
elif selected == "Topper":
total = df.groupby("Name")["Marks"].sum().sort_values(ascending=False)
n = st.number_input(
"How many toppers do you want?",
min_value=1,
max_value=len(total),
value=1
)
st.subheader(f"🏆 Top {n} Students")
st.dataframe(total.head(n))
elif selected == "Search Student":
st.subheader("🔍 Search Student")
search_name = st.text_input("Enter Student Name")
if search_name:
filtered_df = df[df["Name"].str.lower() == search_name.lower()]
if not filtered_df.empty:
st.success(f"Showing results for {search_name}")
st.dataframe(filtered_df)
total = filtered_df["Marks"].sum()
avg = filtered_df["Marks"].mean()
st.write(f"Total Marks: {total}")
st.write(f"Average Marks: {avg}")
else:
st.error("Student not found!")
elif selected == "Subject Analysis":
subject_avg = df.groupby("Subject")["Marks"].mean()
st.subheader("📘 Subject Wise Average")
st.dataframe(subject_avg)
elif selected == "Pass / Fail":
pass_marks = st.slider("Select Passing Marks", 0, 100, 40)
df["Result"] = df["Marks"].apply(
lambda x: "Pass" if x >= pass_marks else "Fail"
)
st.subheader("📌 Result")
st.dataframe(df)
st.subheader("📊 Summary")
st.write(df["Result"].value_counts())
elif selected == "Pivot Table":
pivot = df.pivot_table(
values="Marks",
index="Name",
columns="Subject"
)
st.subheader("📑 Student vs Subject")
st.dataframe(pivot)