Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -57,13 +57,16 @@ def create_trend_chart(space_id, daily_ranks_df):
|
|
57 |
return None
|
58 |
|
59 |
def get_duplicate_spaces(top_100_spaces):
|
60 |
-
# ID
|
61 |
-
|
|
|
|
|
|
|
62 |
|
63 |
# ๋๋ฒ๊น
์ฉ ์ถ๋ ฅ
|
64 |
-
print("\
|
65 |
for id, score in score_sums.sort_values(ascending=False).head(20).items():
|
66 |
-
print(f"{id}: {score}")
|
67 |
|
68 |
# ํฉ์ฐ๋ ์ค์ฝ์ด๋ก ์ ๋ ฌํ์ฌ ์์ 20๊ฐ ์ ํ
|
69 |
top_20_scores = score_sums.sort_values(ascending=False).head(20)
|
@@ -80,12 +83,17 @@ def create_duplicates_chart(score_sums):
|
|
80 |
'rank': range(1, len(score_sums) + 1)
|
81 |
})
|
82 |
|
|
|
|
|
|
|
|
|
83 |
fig = px.bar(
|
84 |
df,
|
85 |
-
x='id',
|
86 |
y='rank',
|
87 |
title="Top 20 Spaces by Combined Trending Score",
|
88 |
-
height=400
|
|
|
89 |
)
|
90 |
|
91 |
fig.update_layout(
|
@@ -95,7 +103,7 @@ def create_duplicates_chart(score_sums):
|
|
95 |
paper_bgcolor='white',
|
96 |
xaxis_tickangle=-45,
|
97 |
yaxis=dict(
|
98 |
-
range=[20.5, 0.5],
|
99 |
tickmode='linear',
|
100 |
tick0=1,
|
101 |
dtick=1
|
@@ -104,13 +112,13 @@ def create_duplicates_chart(score_sums):
|
|
104 |
|
105 |
fig.update_traces(
|
106 |
marker_color='#4CAF50',
|
107 |
-
|
108 |
-
|
|
|
109 |
)
|
110 |
|
111 |
-
# x์ถ ๋ ์ด๋ธ์ ID๋ง ํ์ํ๋๋ก ์ค์
|
112 |
fig.update_xaxes(
|
113 |
-
title_text="
|
114 |
showgrid=True,
|
115 |
gridwidth=1,
|
116 |
gridcolor='lightgray'
|
|
|
57 |
return None
|
58 |
|
59 |
def get_duplicate_spaces(top_100_spaces):
|
60 |
+
# ID์์ username/spacename ํ์์์ username๋ง ์ถ์ถ
|
61 |
+
top_100_spaces['clean_id'] = top_100_spaces['id'].apply(lambda x: x.split('/')[0])
|
62 |
+
|
63 |
+
# username๋ณ trending score ํฉ์ฐ
|
64 |
+
score_sums = top_100_spaces.groupby('clean_id')['trendingScore'].sum()
|
65 |
|
66 |
# ๋๋ฒ๊น
์ฉ ์ถ๋ ฅ
|
67 |
+
print("\n=== ID๋ณ ์ค์ฝ์ด ํฉ์ฐ ๊ฒฐ๊ณผ ===")
|
68 |
for id, score in score_sums.sort_values(ascending=False).head(20).items():
|
69 |
+
print(f"ID: {id}, Total Score: {score}")
|
70 |
|
71 |
# ํฉ์ฐ๋ ์ค์ฝ์ด๋ก ์ ๋ ฌํ์ฌ ์์ 20๊ฐ ์ ํ
|
72 |
top_20_scores = score_sums.sort_values(ascending=False).head(20)
|
|
|
83 |
'rank': range(1, len(score_sums) + 1)
|
84 |
})
|
85 |
|
86 |
+
# ๋๋ฒ๊น
์ฉ ์ถ๋ ฅ
|
87 |
+
print("\n=== ์ฐจํธ ๋ฐ์ดํฐ ===")
|
88 |
+
print(df)
|
89 |
+
|
90 |
fig = px.bar(
|
91 |
df,
|
92 |
+
x='id',
|
93 |
y='rank',
|
94 |
title="Top 20 Spaces by Combined Trending Score",
|
95 |
+
height=400,
|
96 |
+
text='total_score' # ์ค์ฝ์ด ๊ฐ์ ๋ฐ ์์ ํ์
|
97 |
)
|
98 |
|
99 |
fig.update_layout(
|
|
|
103 |
paper_bgcolor='white',
|
104 |
xaxis_tickangle=-45,
|
105 |
yaxis=dict(
|
106 |
+
range=[20.5, 0.5],
|
107 |
tickmode='linear',
|
108 |
tick0=1,
|
109 |
dtick=1
|
|
|
112 |
|
113 |
fig.update_traces(
|
114 |
marker_color='#4CAF50',
|
115 |
+
texttemplate='%{text:.1f}', # ์ค์ฝ์ด ํฌ๋งท
|
116 |
+
textposition='outside',
|
117 |
+
hovertemplate='ID: %{x}<br>Rank: %{y}<br>Total Score: %{text:.1f}<extra></extra>'
|
118 |
)
|
119 |
|
|
|
120 |
fig.update_xaxes(
|
121 |
+
title_text="User ID",
|
122 |
showgrid=True,
|
123 |
gridwidth=1,
|
124 |
gridcolor='lightgray'
|