Spaces:
Runtime error
Runtime error
Commit
·
51a0039
1
Parent(s):
e14b79b
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
|
5 |
+
URL = "https://docs.google.com/spreadsheets/d/1pJPFxqbWeASWi4KZAPf7Go7b46y_7sHePmf-vPRD67I/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 |
+
with gr.Blocks() as demo:
|
18 |
+
gr.Markdown("# 📈 Twitter Trends - Qatar using Real-Time Line and Scatter Plot")
|
19 |
+
gr.Markdown("Following are the current top twitter trending topics in Qatar, Trends last updated every 30 minutes !")
|
20 |
+
with gr.Row():
|
21 |
+
gr.LinePlot(get_data, x="Trending Topic / Hashtag", y="Tweet Volume", tooltip=["Trending Topic / Hashtag","Tweet Volume"] , every=5, overlay_point=True, width=500, height=500, title='Real-Time Line Plot')
|
22 |
+
gr.ScatterPlot(get_data, y="Tweet Volume", x="Trending Topic / Hashtag", tooltip=["Trending Topic / Hashtag","Tweet Volume"] , every=5, width=500, height=500, title='Real-Time Scatter Plot')
|
23 |
+
with gr.Row():
|
24 |
+
gr.DataFrame(get_data, every=5)
|
25 |
+
demo.queue().launch() # Run the demo with queuing enabled
|