James McCool
commited on
Commit
·
db00ed7
1
Parent(s):
37d804e
Add duplication info tab and update dataframe handling in app.py
Browse files- Introduced a new tab for displaying duplication information alongside player and stack data.
- Added calculations for duplicate counts across various player sets, enhancing data analysis capabilities.
- Updated dataframe display logic to include duplication metrics, ensuring consistent styling and formatting.
- Improved overall user experience by providing comprehensive insights into player usage and duplication trends.
app.py
CHANGED
|
@@ -240,10 +240,15 @@ with tab2:
|
|
| 240 |
stack_5per_counts = pd.Series(list(players_5per['stack'])).value_counts()
|
| 241 |
stack_10per_counts = pd.Series(list(players_10per['stack'])).value_counts()
|
| 242 |
stack_20per_counts = pd.Series(list(players_20per['stack'])).value_counts()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
each_set_name = ['Overall', ' Top 1%', ' Top 5%', 'Top 10%', 'Top 20%']
|
| 244 |
each_frame_set = [contest_players, players_1per, players_5per, players_10per, players_20per]
|
| 245 |
with st.container():
|
| 246 |
-
tab1, tab2 = st.tabs(['Player Used Info', 'Stack Used Info'])
|
| 247 |
with tab1:
|
| 248 |
player_count_var = 0
|
| 249 |
for each_set in [player_counts, player_1per_counts, player_5per_counts, player_10per_counts, player20_per_counts]:
|
|
@@ -257,10 +262,10 @@ with tab2:
|
|
| 257 |
st.session_state['player_frame'] = pd.merge(st.session_state['player_frame'], set_frame, on='Player', how='outer')
|
| 258 |
player_count_var += 1
|
| 259 |
st.dataframe(st.session_state['player_frame'].
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
with tab2:
|
| 265 |
stack_count_var = 0
|
| 266 |
for each_set in [stack_counts, stack_1per_counts, stack_5per_counts, stack_10per_counts, stack_20per_counts]:
|
|
@@ -274,7 +279,24 @@ with tab2:
|
|
| 274 |
st.session_state['stack_frame'] = pd.merge(st.session_state['stack_frame'], set_frame, on='Stack', how='outer')
|
| 275 |
stack_count_var += 1
|
| 276 |
st.dataframe(st.session_state['stack_frame'].
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
stack_5per_counts = pd.Series(list(players_5per['stack'])).value_counts()
|
| 241 |
stack_10per_counts = pd.Series(list(players_10per['stack'])).value_counts()
|
| 242 |
stack_20per_counts = pd.Series(list(players_20per['stack'])).value_counts()
|
| 243 |
+
dupe_counts = pd.Series(list(contest_players['dupes'])).value_counts()
|
| 244 |
+
dupe_1per_counts = pd.Series(list(players_1per['dupes'])).value_counts()
|
| 245 |
+
dupe_5per_counts = pd.Series(list(players_5per['dupes'])).value_counts()
|
| 246 |
+
dupe_10per_counts = pd.Series(list(players_10per['dupes'])).value_counts()
|
| 247 |
+
dupe_20per_counts = pd.Series(list(players_20per['dupes'])).value_counts()
|
| 248 |
each_set_name = ['Overall', ' Top 1%', ' Top 5%', 'Top 10%', 'Top 20%']
|
| 249 |
each_frame_set = [contest_players, players_1per, players_5per, players_10per, players_20per]
|
| 250 |
with st.container():
|
| 251 |
+
tab1, tab2, tab3 = st.tabs(['Player Used Info', 'Stack Used Info', 'Duplication Info'])
|
| 252 |
with tab1:
|
| 253 |
player_count_var = 0
|
| 254 |
for each_set in [player_counts, player_1per_counts, player_5per_counts, player_10per_counts, player20_per_counts]:
|
|
|
|
| 262 |
st.session_state['player_frame'] = pd.merge(st.session_state['player_frame'], set_frame, on='Player', how='outer')
|
| 263 |
player_count_var += 1
|
| 264 |
st.dataframe(st.session_state['player_frame'].
|
| 265 |
+
sort_values(by='Exposure Overall', ascending=False).
|
| 266 |
+
style.background_gradient(cmap='RdYlGn').
|
| 267 |
+
format(formatter='{:.2%}', subset=st.session_state['player_frame'].select_dtypes(include=['number']).columns),
|
| 268 |
+
hide_index=True)
|
| 269 |
with tab2:
|
| 270 |
stack_count_var = 0
|
| 271 |
for each_set in [stack_counts, stack_1per_counts, stack_5per_counts, stack_10per_counts, stack_20per_counts]:
|
|
|
|
| 279 |
st.session_state['stack_frame'] = pd.merge(st.session_state['stack_frame'], set_frame, on='Stack', how='outer')
|
| 280 |
stack_count_var += 1
|
| 281 |
st.dataframe(st.session_state['stack_frame'].
|
| 282 |
+
sort_values(by='Exposure Overall', ascending=False).
|
| 283 |
+
style.background_gradient(cmap='RdYlGn').
|
| 284 |
+
format(formatter='{:.2%}', subset=st.session_state['stack_frame'].select_dtypes(include=['number']).columns),
|
| 285 |
+
hide_index=True)
|
| 286 |
+
with tab3:
|
| 287 |
+
dupe_count_var = 0
|
| 288 |
+
for each_set in [dupe_counts, dupe_1per_counts, dupe_5per_counts, dupe_10per_counts, dupe_20per_counts]:
|
| 289 |
+
set_frame = each_set.to_frame().reset_index().rename(columns={'index': 'Dupes', 'count': 'Count'})
|
| 290 |
+
set_frame['Percent'] = set_frame['Count'] / len(each_frame_set[dupe_count_var])
|
| 291 |
+
set_frame = set_frame[['Dupes', 'Percent']]
|
| 292 |
+
set_frame = set_frame.rename(columns={'Percent': f'Exposure {each_set_name[stack_count_var]}'})
|
| 293 |
+
if 'dupe_frame' not in st.session_state:
|
| 294 |
+
st.session_state['dupe_frame'] = set_frame
|
| 295 |
+
else:
|
| 296 |
+
st.session_state['dupe_frame'] = pd.merge(st.session_state['dupe_frame'], set_frame, on='Dupes', how='outer')
|
| 297 |
+
stack_count_var += 1
|
| 298 |
+
st.dataframe(st.session_state['dupe_frame'].
|
| 299 |
+
sort_values(by='Exposure Overall', ascending=False).
|
| 300 |
+
style.background_gradient(cmap='RdYlGn').
|
| 301 |
+
format(formatter='{:.2%}', subset=st.session_state['dupe_frame'].select_dtypes(include=['number']).columns),
|
| 302 |
+
hide_index=True)
|