evijit HF Staff commited on
Commit
4d0811f
·
verified ·
1 Parent(s): 98b7de8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -216,7 +216,6 @@ def create_treemap(treemap_data, count_by, title=None):
216
  return fig
217
 
218
  def load_models_csv():
219
-
220
  # Read the CSV file
221
  df = pd.read_csv('models.csv')
222
 
@@ -470,19 +469,21 @@ with gr.Blocks() as demo:
470
  total_value = treemap_data[count_by].sum()
471
  top_5_orgs = treemap_data.groupby("organization")[count_by].sum().sort_values(ascending=False).head(5)
472
 
 
473
  stats_md = f"""
474
- ### Statistics
475
- - **Total models shown**: {total_models:,}
476
- - **Total {count_by}**: {total_value:,}
477
-
478
- ### Top 5 Organizations
479
- | Organization | {count_by.capitalize()} | % of Total |
480
- | --- | --- | --- |
481
- """
482
 
 
483
  for org, value in top_5_orgs.items():
484
  percentage = (value / total_value) * 100
485
- stats_md += f"| {org} | {value:,} | {percentage:.2f}% |\n"
486
 
487
  return fig, stats_md
488
 
 
216
  return fig
217
 
218
  def load_models_csv():
 
219
  # Read the CSV file
220
  df = pd.read_csv('models.csv')
221
 
 
469
  total_value = treemap_data[count_by].sum()
470
  top_5_orgs = treemap_data.groupby("organization")[count_by].sum().sort_values(ascending=False).head(5)
471
 
472
+ # Format the statistics using clean markdown
473
  stats_md = f"""
474
+ ## Statistics
475
+ - **Total models shown**: {total_models:,}
476
+ - **Total {count_by}**: {int(total_value):,}
477
+
478
+ ## Top Organizations by {count_by.capitalize()}
479
+
480
+ | Organization | {count_by.capitalize()} | % of Total |
481
+ |--------------|--------:|--------:|"""
482
 
483
+ # Add each organization as a row in the table
484
  for org, value in top_5_orgs.items():
485
  percentage = (value / total_value) * 100
486
+ stats_md += f"\n| {org} | {int(value):,} | {percentage:.2f}% |"
487
 
488
  return fig, stats_md
489