ysharma HF Staff commited on
Commit
1f603f5
·
1 Parent(s): d550178

create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import gradio as gr
3
+
4
+
5
+ URL = "https://docs.google.com/spreadsheets/d/1qFJ7N4yubNyq7BBvLiNFcgpyWFV66wDGCa48axGNp_c/edit?usp=sharing"
6
+ csv_url = URL.replace('/edit?usp=', '/export?format=csv&usp=')
7
+
8
+ def get_data():
9
+ df = pd.read_csv(csv_url)
10
+ df['Tweet Volume'] = df['Tweet Volume'].str[:-1]
11
+ df['Tweet Volume'] = df['Tweet Volume'].transform( lambda x: x[-2:] if 'Under' in x else x)
12
+ df['Trending Topic / Hashtag'] = df['Trending Topic / Hashtag'].transform( lambda x: x.split()[0])
13
+ df["Tweet Volume"] = pd.to_numeric(df["Tweet Volume"])
14
+ df = df.sort_values(by=['Tweet Volume'], ascending=False)
15
+ return df[["Trending Topic / Hashtag", "Tweet Volume"]][:15]
16
+
17
+
18
+ with gr.Blocks() as demo:
19
+ gr.Markdown("# 📈 Real-Time Line Plot")
20
+ with gr.Row():
21
+ with gr.Column():
22
+ gr.DataFrame(get_data, every=5)
23
+ with gr.Column():
24
+ gr.LinePlot(get_data, x="Trending Topic / Hashtag", y="Tweet Volume", every=5, overlay_point=True, width=500, height=500)
25
+ gr.ScatterPlot(get_data, y="Tweet Volume", x="Trending Topic / Hashtag", every=5, width=500, height=500)
26
+ demo.queue().launch() # Run the demo with queuing enabled