kargaranamir commited on
Commit
da22b94
•
1 Parent(s): ca19aec

sort based on the color codes then iso code.

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -17,20 +17,19 @@ def render_home_table():
17
  df_data = pd.DataFrame(data).transpose()
18
  df_data['ISO Code'] = df_data.index
19
 
20
- # Sort by ISO Code
21
- df_data = df_data.sort_values(by='ISO Code')
22
-
23
  df_data['Number of Sites'] = df_data['Number of Sites'].astype(str) # Convert to string
24
  df_data['ISO Code'] = df_data['ISO Code'].astype(str) # Convert to string
25
  df_data['Number of Sites'] = df_data.apply(lambda row: '<a href="/?isocode={}&site=True" target="_self">{}</a>'.format(row['ISO Code'], row['Number of Sites']), axis=1)
26
  df_data['Number of Links'] = df_data.apply(lambda row: '<a href="/?isocode={}&links=True" target="_self">{}</a>'.format(row['ISO Code'], row['Number of Links']), axis=1)
27
- df_data["Supported by MADLAD400 & FLORES & GLOT500"] = df_data.apply(lambda row: color_mapping([row["Supported by allenai/MADLAD-400"] + row["Supported by facebook/flores"] + row["Supported by cis-lmu/Glot500"]]), axis =1)
 
 
 
28
 
29
  # Display the table
30
- df_data = df_data[['ISO Code', 'Language Name', 'Family', 'Subgrouping', 'Number of Sites', 'Number of Links', 'Number of Speakers', 'Supported by MADLAD400 & FLORES & GLOT500']]
31
  st.write(df_to_html(df_data), unsafe_allow_html=True)
32
 
33
-
34
  @st.cache_data
35
  def render_site_table(isocode):
36
 
 
17
  df_data = pd.DataFrame(data).transpose()
18
  df_data['ISO Code'] = df_data.index
19
 
 
 
 
20
  df_data['Number of Sites'] = df_data['Number of Sites'].astype(str) # Convert to string
21
  df_data['ISO Code'] = df_data['ISO Code'].astype(str) # Convert to string
22
  df_data['Number of Sites'] = df_data.apply(lambda row: '<a href="/?isocode={}&site=True" target="_self">{}</a>'.format(row['ISO Code'], row['Number of Sites']), axis=1)
23
  df_data['Number of Links'] = df_data.apply(lambda row: '<a href="/?isocode={}&links=True" target="_self">{}</a>'.format(row['ISO Code'], row['Number of Links']), axis=1)
24
+ df_data["Supported by MADLAD400, FLORES200, GLOT500"] = df_data.apply(lambda row: color_mapping([row["Supported by allenai/MADLAD-400"] + row["Supported by facebook/flores"] + row["Supported by cis-lmu/Glot500"]]), axis =1)
25
+ df_data['Color_Order'] = pd.Categorical(df_data['Supported by MADLAD400, FLORES200, GLOT500'], categories=['🟥', '🟧', '🟨', '🟩'], ordered=True)
26
+ # Sort by Color_Order then ISO Code
27
+ df_data = df_data.sort_values(by=['Color_Order', 'ISO Code'])
28
 
29
  # Display the table
30
+ df_data = df_data[['ISO Code', 'Language Name', 'Family', 'Subgrouping', 'Number of Sites', 'Number of Links', 'Number of Speakers', 'Supported by MADLAD400, FLORES200, GLOT500']]
31
  st.write(df_to_html(df_data), unsafe_allow_html=True)
32
 
 
33
  @st.cache_data
34
  def render_site_table(isocode):
35