lunarflu HF staff commited on
Commit
66cef69
β€’
1 Parent(s): 5b24125
Files changed (1) hide show
  1. app.py +51 -4
app.py CHANGED
@@ -323,8 +323,27 @@ async def xp_help(ctx):
323
  # add emojis for some color
324
  # check if members are still in the server
325
 
 
 
 
 
 
 
326
  """"""
 
 
 
 
327
 
 
 
 
 
 
 
 
 
 
328
 
329
  # csv
330
  # read into pandas dataframe1
@@ -333,14 +352,42 @@ async def xp_help(ctx):
333
 
334
  demo = gr.Blocks()
335
  with demo:
 
 
 
 
 
 
 
 
 
 
 
336
  TITLE = """<h1 align="center" id="space-title">πŸ€— Hugging Face Level Leaderboard</h1>"""
337
  gr.HTML(TITLE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
338
  demo.queue().launch()
339
 
340
 
341
- DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
342
- def run_bot():
343
- bot.run(DISCORD_TOKEN)
344
- threading.Thread(target=run_bot).start()
345
 
346
 
 
323
  # add emojis for some color
324
  # check if members are still in the server
325
 
326
+
327
+
328
+
329
+
330
+
331
+
332
  """"""
333
+ DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
334
+ def run_bot():
335
+ bot.run(DISCORD_TOKEN)
336
+ threading.Thread(target=run_bot).start()
337
 
338
+ URL = "https://docs.google.com/spreadsheets/d/1hQSsIg1Y9WdBF_CdNM1L1rUUREoxKqRTe3_ILo-WK8w/edit#gid=0"
339
+ csv_url = URL.replace('/edit#gid=', '/export?format=csv&gid=')
340
+
341
+
342
+ def get_data():
343
+ data = pd.read_csv(csv_url)
344
+ first_3_columns = data.iloc[:, 1:4]
345
+ first_3_columns.to_csv('first_3_columns.csv', index=False)
346
+ return first_3_columns
347
 
348
  # csv
349
  # read into pandas dataframe1
 
352
 
353
  demo = gr.Blocks()
354
  with demo:
355
+ dataframe1 = pd.read_csv(csv_url)
356
+ column_values_unique = sorted(dataframe1.iloc[:, 3].unique())
357
+ dataframe2 = pd.DataFrame({'Levels': column_values_unique})
358
+ counts = {}
359
+ for value in data.iloc[:, 3]:
360
+ counts[value] = counts.get(value, 0) + 1
361
+ dataframe2['Members'] = dataframe2['Levels'].map(counts)
362
+
363
+ print("\nDataframe 2:")
364
+ print(dataframe2)
365
+
366
  TITLE = """<h1 align="center" id="space-title">πŸ€— Hugging Face Level Leaderboard</h1>"""
367
  gr.HTML(TITLE)
368
+ with gr.Tabs(elem_classes="tab-buttons") as tabs:
369
+ with gr.TabItem("πŸ… Level leaderboard", elem_id="level-table", id=0):
370
+ #gr.Markdown("# πŸ“ˆ Experience Leaderboard")
371
+ with gr.Row():
372
+ with gr.Column():
373
+ gr.DataFrame(get_data, every=5, height=500, interactive=False, col_count=(3, "fixed"), column_widths=["100px","100px","100px"])
374
+
375
+ with gr.Column():
376
+ gr.BarPlot(
377
+ value=dataframe2,
378
+ x="Levels",
379
+ y="Members",
380
+ title="Level Distribution",
381
+ height=450,
382
+ width=450,
383
+ interactive=False
384
+ )
385
+ #with gr.TabItem("πŸ“ˆ Members of the Week", elem_id="week-table", id=1):
386
+
387
+ #with gr.TabItem("πŸ“ˆ Hub-only leaderboard", elem_id="hub-table", id=2):
388
+
389
  demo.queue().launch()
390
 
391
 
 
 
 
 
392
 
393