James McCool
commited on
Commit
·
c65f6e6
1
Parent(s):
c5a8033
Add percentile finish calculation in app.py
Browse files- Introduced a new column 'percentile_finish' to calculate the percentile rank of 'actual_fpts' for players, enhancing the metrics available for analysis.
- This change improves the granularity of player performance insights and supports future enhancements in data processing and visualization.
app.py
CHANGED
@@ -147,6 +147,7 @@ with tab2:
|
|
147 |
axis=1
|
148 |
)
|
149 |
working_df['dupes'] = working_df.groupby('sorted').transform('size')
|
|
|
150 |
working_df = working_df.drop('sorted', axis=1)
|
151 |
elif type_var == 'Showdown':
|
152 |
working_df['stack'] = working_df.apply(
|
@@ -183,6 +184,7 @@ with tab2:
|
|
183 |
axis=1
|
184 |
)
|
185 |
working_df['dupes'] = working_df.groupby('sorted').transform('size')
|
|
|
186 |
working_df = working_df.drop('sorted', axis=1)
|
187 |
|
188 |
# Initialize pagination in session state if not exists
|
@@ -236,6 +238,7 @@ with tab2:
|
|
236 |
len_5per = len(st.session_state['Contest']) * 0.05
|
237 |
len_10per = len(st.session_state['Contest']) * 0.10
|
238 |
len_20per = len(st.session_state['Contest']) * 0.20
|
|
|
239 |
player_counts = pd.Series(list(contest_players[player_columns].values.flatten())).value_counts()
|
240 |
player_1per_counts = pd.Series(list(players_1per[player_columns].values.flatten())).value_counts()
|
241 |
player_5per_counts = pd.Series(list(players_5per[player_columns].values.flatten())).value_counts()
|
|
|
147 |
axis=1
|
148 |
)
|
149 |
working_df['dupes'] = working_df.groupby('sorted').transform('size')
|
150 |
+
working_df['percentile_finish'] = working_df['actual_fpts'].rank(pct=True)
|
151 |
working_df = working_df.drop('sorted', axis=1)
|
152 |
elif type_var == 'Showdown':
|
153 |
working_df['stack'] = working_df.apply(
|
|
|
184 |
axis=1
|
185 |
)
|
186 |
working_df['dupes'] = working_df.groupby('sorted').transform('size')
|
187 |
+
working_df['percentile_finish'] = working_df['actual_fpts'].rank(pct=True)
|
188 |
working_df = working_df.drop('sorted', axis=1)
|
189 |
|
190 |
# Initialize pagination in session state if not exists
|
|
|
238 |
len_5per = len(st.session_state['Contest']) * 0.05
|
239 |
len_10per = len(st.session_state['Contest']) * 0.10
|
240 |
len_20per = len(st.session_state['Contest']) * 0.20
|
241 |
+
######## Going to try a groupby based on finishing percentiles here next
|
242 |
player_counts = pd.Series(list(contest_players[player_columns].values.flatten())).value_counts()
|
243 |
player_1per_counts = pd.Series(list(players_1per[player_columns].values.flatten())).value_counts()
|
244 |
player_5per_counts = pd.Series(list(players_5per[player_columns].values.flatten())).value_counts()
|