Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -31,22 +31,19 @@ with tab2:
|
|
31 |
st.table(selected_country.reset_index(drop=True))
|
32 |
|
33 |
with tab3:
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
num_results = st.slider('Number of results to display:', min_value=5, max_value=50, value=10)
|
39 |
-
|
40 |
ranking_df = df.sort_values(by=metric, ascending=False)[['name', 'location', metric]].head(num_results)
|
41 |
st.write(f"Top {num_results} Universities by {metric.replace('scores_', '').title()}:")
|
42 |
st.table(ranking_df)
|
43 |
|
44 |
-
# Calculate country distribution and show
|
45 |
country_count = ranking_df['location'].value_counts()
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
st.write(f"{country}: {count}")
|
50 |
|
51 |
with tab4:
|
52 |
# Calculate the average score for each university
|
|
|
31 |
st.table(selected_country.reset_index(drop=True))
|
32 |
|
33 |
with tab3:
|
34 |
+
metric = st.selectbox('Select a metric for ranking:',
|
35 |
+
['scores_teaching', 'scores_research', 'scores_citations'], key='metric_select')
|
36 |
+
num_results = st.slider('Number of results to display:', min_value=5, max_value=50, value=10, key='num_results_slider')
|
37 |
+
|
|
|
|
|
38 |
ranking_df = df.sort_values(by=metric, ascending=False)[['name', 'location', metric]].head(num_results)
|
39 |
st.write(f"Top {num_results} Universities by {metric.replace('scores_', '').title()}:")
|
40 |
st.table(ranking_df)
|
41 |
|
42 |
+
# Calculate country distribution and show it within the rankings tab, not sidebar
|
43 |
country_count = ranking_df['location'].value_counts()
|
44 |
+
st.subheader('Country Distribution')
|
45 |
+
for country, count in country_count.items():
|
46 |
+
st.write(f"{country}: {count}")
|
|
|
47 |
|
48 |
with tab4:
|
49 |
# Calculate the average score for each university
|