Karlsen commited on
Commit
8cbe5e9
1 Parent(s): 6973ae7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -31,22 +31,19 @@ with tab2:
31
  st.table(selected_country.reset_index(drop=True))
32
 
33
  with tab3:
34
- # Show sidebar elements only when in the Rankings tab
35
- with st.sidebar:
36
- metric = st.selectbox('Select a metric for ranking:',
37
- ['scores_teaching', 'scores_research', 'scores_citations'])
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 in sidebar
45
  country_count = ranking_df['location'].value_counts()
46
- with st.sidebar:
47
- st.header('Country Distribution')
48
- for country, count in country_count.items():
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