Spaces:
Sleeping
Sleeping
James McCool commited on
Commit ·
ea70db3
1
Parent(s): 64d473e
Remove redundant player name mappings in VORP roster assignment to streamline data processing and enhance clarity in player rankings display.
Browse files- src/streamlit_app.py +3 -4
src/streamlit_app.py
CHANGED
|
@@ -393,7 +393,7 @@ def assign_vorp_scoring(frame: pd.DataFrame, halfPpr_rv: dict, custom_rv: dict,
|
|
| 393 |
|
| 394 |
return pos_des_dict, orig_rank_dict, half_ppr_match_dict, custom_match_dict
|
| 395 |
|
| 396 |
-
def assign_vorp_roster(frame: pd.DataFrame, halfPpr_rv: dict, custom_rv: dict, pos_vorp_limiters: dict, half_ppr_match_dict: dict, custom_match_dict: dict) -> pd.DataFrame:
|
| 397 |
|
| 398 |
vorp_frame = pd.DataFrame()
|
| 399 |
for positions in ['QB', 'RB', 'WR', 'TE']:
|
|
@@ -402,6 +402,7 @@ def assign_vorp_roster(frame: pd.DataFrame, halfPpr_rv: dict, custom_rv: dict, p
|
|
| 402 |
pos_frame = pos_frame.sort_values(by='Rank', ascending=True).reset_index(drop=True)
|
| 403 |
pos_frame['ranker_rank'] = pos_frame['Rank'].rank(method='first', ascending=True).astype(int)
|
| 404 |
pos_frame['pos_rank_init'] = pos_frame['Pos'] + pos_frame['ranker_rank'].astype(str)
|
|
|
|
| 405 |
pos_frame['halfPpr_lu'] = pos_frame['pos_rank_init'].map(half_ppr_match_dict)
|
| 406 |
pos_frame['custom_lu'] = pos_frame['pos_rank_init'].map(custom_match_dict)
|
| 407 |
|
|
@@ -447,10 +448,8 @@ def main():
|
|
| 447 |
|
| 448 |
# Calculate VORP and rankings
|
| 449 |
pos_des_dict, orig_rank_dict, half_ppr_match_dict, custom_match_dict = assign_vorp_scoring(position_df, halfPpr_rv, custom_scoring_rv, user_league_settings, user_pos_vorp_limiters)
|
| 450 |
-
final_df = assign_vorp_roster(position_df, halfPpr_rv, custom_roster_rv, user_pos_vorp_limiters, half_ppr_match_dict, custom_match_dict)
|
| 451 |
final_df = final_df.drop(columns=['SR_ID'], axis=1)
|
| 452 |
-
final_df['Name_Lookup'] = final_df['Name'].map(orig_rank_dict)
|
| 453 |
-
final_df['Name'] = final_df['pos_des'].map(pos_des_dict)
|
| 454 |
|
| 455 |
# Display results
|
| 456 |
st.header("Player Rankings")
|
|
|
|
| 393 |
|
| 394 |
return pos_des_dict, orig_rank_dict, half_ppr_match_dict, custom_match_dict
|
| 395 |
|
| 396 |
+
def assign_vorp_roster(frame: pd.DataFrame, halfPpr_rv: dict, custom_rv: dict, pos_vorp_limiters: dict, half_ppr_match_dict: dict, custom_match_dict: dict, orig_rank_dict: dict) -> pd.DataFrame:
|
| 397 |
|
| 398 |
vorp_frame = pd.DataFrame()
|
| 399 |
for positions in ['QB', 'RB', 'WR', 'TE']:
|
|
|
|
| 402 |
pos_frame = pos_frame.sort_values(by='Rank', ascending=True).reset_index(drop=True)
|
| 403 |
pos_frame['ranker_rank'] = pos_frame['Rank'].rank(method='first', ascending=True).astype(int)
|
| 404 |
pos_frame['pos_rank_init'] = pos_frame['Pos'] + pos_frame['ranker_rank'].astype(str)
|
| 405 |
+
pos_frame['scoring_rank'] = pos_frame['Name'].map(orig_rank_dict)
|
| 406 |
pos_frame['halfPpr_lu'] = pos_frame['pos_rank_init'].map(half_ppr_match_dict)
|
| 407 |
pos_frame['custom_lu'] = pos_frame['pos_rank_init'].map(custom_match_dict)
|
| 408 |
|
|
|
|
| 448 |
|
| 449 |
# Calculate VORP and rankings
|
| 450 |
pos_des_dict, orig_rank_dict, half_ppr_match_dict, custom_match_dict = assign_vorp_scoring(position_df, halfPpr_rv, custom_scoring_rv, user_league_settings, user_pos_vorp_limiters)
|
| 451 |
+
final_df = assign_vorp_roster(position_df, halfPpr_rv, custom_roster_rv, user_pos_vorp_limiters, half_ppr_match_dict, custom_match_dict, orig_rank_dict)
|
| 452 |
final_df = final_df.drop(columns=['SR_ID'], axis=1)
|
|
|
|
|
|
|
| 453 |
|
| 454 |
# Display results
|
| 455 |
st.header("Player Rankings")
|