Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -57,20 +57,20 @@ def create_trend_chart(space_id, daily_ranks_df):
|
|
| 57 |
return None
|
| 58 |
|
| 59 |
def get_duplicate_spaces(top_100_spaces):
|
| 60 |
-
# ID๋ณ trending score
|
| 61 |
-
score_sums = top_100_spaces.groupby('id')['trendingScore'].sum()
|
| 62 |
-
# ์์ 20
|
| 63 |
-
top_20_scores = score_sums.head(20)
|
| 64 |
return top_20_scores
|
| 65 |
|
| 66 |
def create_duplicates_chart(score_sums):
|
| 67 |
if score_sums.empty:
|
| 68 |
return None
|
| 69 |
|
| 70 |
-
#
|
| 71 |
df = pd.DataFrame({
|
| 72 |
'id': score_sums.index,
|
| 73 |
-
'
|
| 74 |
'rank': range(1, len(score_sums) + 1)
|
| 75 |
})
|
| 76 |
|
|
@@ -78,7 +78,7 @@ def create_duplicates_chart(score_sums):
|
|
| 78 |
df,
|
| 79 |
x='id',
|
| 80 |
y='rank',
|
| 81 |
-
title="Top 20 Spaces by
|
| 82 |
labels={'id': 'Space ID', 'rank': 'Rank'},
|
| 83 |
height=400
|
| 84 |
)
|
|
@@ -90,7 +90,7 @@ def create_duplicates_chart(score_sums):
|
|
| 90 |
paper_bgcolor='white',
|
| 91 |
xaxis_tickangle=-45,
|
| 92 |
yaxis=dict(
|
| 93 |
-
range=[20.5, 0.5], #
|
| 94 |
tickmode='linear',
|
| 95 |
tick0=1,
|
| 96 |
dtick=1
|
|
@@ -98,11 +98,22 @@ def create_duplicates_chart(score_sums):
|
|
| 98 |
)
|
| 99 |
|
| 100 |
fig.update_traces(
|
| 101 |
-
marker_color='#4CAF50'
|
|
|
|
| 102 |
)
|
| 103 |
|
| 104 |
-
fig.update_xaxes(
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
return fig
|
| 108 |
|
|
|
|
| 57 |
return None
|
| 58 |
|
| 59 |
def get_duplicate_spaces(top_100_spaces):
|
| 60 |
+
# ID๋ณ trending score ํฉ์ฐ
|
| 61 |
+
score_sums = top_100_spaces.groupby('id')['trendingScore'].sum()
|
| 62 |
+
# ํฉ์ฐ๋ ์ค์ฝ์ด๋ก ์ ๋ ฌํ์ฌ ์์ 20๊ฐ ์ ํ
|
| 63 |
+
top_20_scores = score_sums.sort_values(ascending=False).head(20)
|
| 64 |
return top_20_scores
|
| 65 |
|
| 66 |
def create_duplicates_chart(score_sums):
|
| 67 |
if score_sums.empty:
|
| 68 |
return None
|
| 69 |
|
| 70 |
+
# ๋ฐ์ดํฐํ๋ ์ ์์ฑ (์ธ๋ฑ์ค๋ฅผ 1๋ถํฐ ์์ํ๋ ์์๋ก)
|
| 71 |
df = pd.DataFrame({
|
| 72 |
'id': score_sums.index,
|
| 73 |
+
'total_score': score_sums.values,
|
| 74 |
'rank': range(1, len(score_sums) + 1)
|
| 75 |
})
|
| 76 |
|
|
|
|
| 78 |
df,
|
| 79 |
x='id',
|
| 80 |
y='rank',
|
| 81 |
+
title="Top 20 Spaces by Combined Trending Score",
|
| 82 |
labels={'id': 'Space ID', 'rank': 'Rank'},
|
| 83 |
height=400
|
| 84 |
)
|
|
|
|
| 90 |
paper_bgcolor='white',
|
| 91 |
xaxis_tickangle=-45,
|
| 92 |
yaxis=dict(
|
| 93 |
+
range=[20.5, 0.5], # ์์ ์ญ์์ผ๋ก ํ์ (1์ด ์์ชฝ)
|
| 94 |
tickmode='linear',
|
| 95 |
tick0=1,
|
| 96 |
dtick=1
|
|
|
|
| 98 |
)
|
| 99 |
|
| 100 |
fig.update_traces(
|
| 101 |
+
marker_color='#4CAF50',
|
| 102 |
+
hovertemplate='ID: %{x}<br>Rank: %{y}<extra></extra>'
|
| 103 |
)
|
| 104 |
|
| 105 |
+
fig.update_xaxes(
|
| 106 |
+
showgrid=True,
|
| 107 |
+
gridwidth=1,
|
| 108 |
+
gridcolor='lightgray',
|
| 109 |
+
title_text="Space ID"
|
| 110 |
+
)
|
| 111 |
+
fig.update_yaxes(
|
| 112 |
+
showgrid=True,
|
| 113 |
+
gridwidth=1,
|
| 114 |
+
gridcolor='lightgray',
|
| 115 |
+
title_text="Rank"
|
| 116 |
+
)
|
| 117 |
|
| 118 |
return fig
|
| 119 |
|