Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -212,13 +212,26 @@ if fetch_data:
|
|
212 |
"""
|
213 |
stats_placeholder.markdown(stats_html, unsafe_allow_html=True)
|
214 |
|
215 |
-
|
216 |
-
st.subheader("Most Common Subjects")
|
217 |
if 'subject' in metadata_df.columns:
|
218 |
-
top_subjects =
|
219 |
-
|
220 |
-
|
221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
|
223 |
with st.sidebar.expander("π Helpful Resources", expanded=False):
|
224 |
st.markdown("""
|
|
|
212 |
"""
|
213 |
stats_placeholder.markdown(stats_html, unsafe_allow_html=True)
|
214 |
|
215 |
+
# Calculate Top 10 Subjects
|
|
|
216 |
if 'subject' in metadata_df.columns:
|
217 |
+
top_subjects = (
|
218 |
+
metadata_df['subject']
|
219 |
+
.dropna()
|
220 |
+
.str.split(',') # Split multiple subjects per record
|
221 |
+
.explode() # Expand into separate rows
|
222 |
+
.str.strip() # Remove whitespace
|
223 |
+
.value_counts()
|
224 |
+
.head(10)
|
225 |
+
.to_frame(name="Count")
|
226 |
+
)
|
227 |
+
|
228 |
+
# π Most Common Subjects in Sidebar
|
229 |
+
with st.sidebar.expander("Top 10 Most Common Subjects", expanded=True):
|
230 |
+
st.dataframe(
|
231 |
+
top_subjects.style.background_gradient(cmap="Greens").format("{:.0f}"),
|
232 |
+
use_container_width=True,
|
233 |
+
height=240
|
234 |
+
)
|
235 |
|
236 |
with st.sidebar.expander("π Helpful Resources", expanded=False):
|
237 |
st.markdown("""
|