Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,7 @@ def create_trend_chart(space_id, daily_ranks_df):
|
|
23 |
title=f'Daily Rank Trend for {space_id}',
|
24 |
labels={'date': 'Date', 'rank': 'Rank'},
|
25 |
markers=True,
|
26 |
-
height=400
|
27 |
)
|
28 |
|
29 |
fig.update_layout(
|
@@ -56,6 +56,39 @@ def create_trend_chart(space_id, daily_ranks_df):
|
|
56 |
print(f"Error creating chart: {e}")
|
57 |
return None
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
def update_display(selection):
|
60 |
global daily_ranks_df
|
61 |
|
@@ -134,6 +167,10 @@ print("Loading initial data...")
|
|
134 |
daily_ranks_df, top_100_spaces = load_and_process_data()
|
135 |
print("Data loaded successfully!")
|
136 |
|
|
|
|
|
|
|
|
|
137 |
# Gradio ์ธํฐํ์ด์ค ์์ฑ
|
138 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
139 |
gr.Markdown("""
|
@@ -145,10 +182,17 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
145 |
with gr.Tabs():
|
146 |
with gr.Tab("Dashboard"):
|
147 |
with gr.Row(variant="panel"):
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
|
153 |
with gr.Row():
|
154 |
info_box = gr.HTML(
|
@@ -264,4 +308,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
264 |
)
|
265 |
|
266 |
if __name__ == "__main__":
|
267 |
-
demo.launch(share=True)
|
|
|
23 |
title=f'Daily Rank Trend for {space_id}',
|
24 |
labels={'date': 'Date', 'rank': 'Rank'},
|
25 |
markers=True,
|
26 |
+
height=400
|
27 |
)
|
28 |
|
29 |
fig.update_layout(
|
|
|
56 |
print(f"Error creating chart: {e}")
|
57 |
return None
|
58 |
|
59 |
+
def get_duplicate_spaces(top_100_spaces):
|
60 |
+
# ID๋ณ ๋ฑ์ฅ ํ์ ๊ณ์ฐ
|
61 |
+
id_counts = top_100_spaces['id'].value_counts()
|
62 |
+
# 2ํ ์ด์ ๋ฑ์ฅํ๋ ID๋ง ํํฐ๋ง
|
63 |
+
duplicates = id_counts[id_counts >= 2]
|
64 |
+
return duplicates
|
65 |
+
|
66 |
+
def create_duplicates_chart(duplicates):
|
67 |
+
if duplicates.empty:
|
68 |
+
return None
|
69 |
+
|
70 |
+
fig = px.bar(
|
71 |
+
x=duplicates.index,
|
72 |
+
y=duplicates.values,
|
73 |
+
title="Spaces with Multiple Entries in Top 100",
|
74 |
+
labels={'x': 'Space ID', 'y': 'Number of Entries'},
|
75 |
+
height=400
|
76 |
+
)
|
77 |
+
|
78 |
+
fig.update_layout(
|
79 |
+
showlegend=False,
|
80 |
+
margin=dict(t=50, r=20, b=40, l=40),
|
81 |
+
plot_bgcolor='white',
|
82 |
+
paper_bgcolor='white',
|
83 |
+
xaxis_tickangle=-45
|
84 |
+
)
|
85 |
+
|
86 |
+
fig.update_traces(
|
87 |
+
marker_color='#4CAF50'
|
88 |
+
)
|
89 |
+
|
90 |
+
return fig
|
91 |
+
|
92 |
def update_display(selection):
|
93 |
global daily_ranks_df
|
94 |
|
|
|
167 |
daily_ranks_df, top_100_spaces = load_and_process_data()
|
168 |
print("Data loaded successfully!")
|
169 |
|
170 |
+
# ์ค๋ณต ์คํ์ด์ค ๋ฐ์ดํฐ ๊ณ์ฐ
|
171 |
+
duplicates = get_duplicate_spaces(top_100_spaces)
|
172 |
+
duplicates_chart = create_duplicates_chart(duplicates)
|
173 |
+
|
174 |
# Gradio ์ธํฐํ์ด์ค ์์ฑ
|
175 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
176 |
gr.Markdown("""
|
|
|
182 |
with gr.Tabs():
|
183 |
with gr.Tab("Dashboard"):
|
184 |
with gr.Row(variant="panel"):
|
185 |
+
with gr.Column(scale=7):
|
186 |
+
trend_plot = gr.Plot(
|
187 |
+
label="Daily Rank Trend",
|
188 |
+
container=True
|
189 |
+
)
|
190 |
+
with gr.Column(scale=3):
|
191 |
+
duplicates_plot = gr.Plot(
|
192 |
+
label="Multiple Entries Analysis",
|
193 |
+
value=duplicates_chart,
|
194 |
+
container=True
|
195 |
+
)
|
196 |
|
197 |
with gr.Row():
|
198 |
info_box = gr.HTML(
|
|
|
308 |
)
|
309 |
|
310 |
if __name__ == "__main__":
|
311 |
+
demo.launch(share=True)
|