Spaces:
Sleeping
Sleeping
James McCool commited on
Commit ·
64d473e
1
Parent(s): fbf8938
Remove match_back_dict from VORP scoring and roster assignment functions in Streamlit app to streamline player name mapping, enhancing clarity and simplifying function signatures.
Browse files- src/streamlit_app.py +3 -4
src/streamlit_app.py
CHANGED
|
@@ -387,14 +387,13 @@ def assign_vorp_scoring(frame: pd.DataFrame, halfPpr_rv: dict, custom_rv: dict,
|
|
| 387 |
orig_rank_dict = dict(zip(vorp_frame['Name'], vorp_frame['pos_designation']))
|
| 388 |
half_ppr_match_dict = dict(zip(vorp_frame['pos_designation'], vorp_frame['halfPpr']))
|
| 389 |
custom_match_dict = dict(zip(vorp_frame['pos_designation'], vorp_frame[rv_type]))
|
| 390 |
-
match_back_dict = dict(zip(vorp_frame[rv_type], vorp_frame['Name']))
|
| 391 |
|
| 392 |
for pos in ['QB', 'RB', 'WR', 'TE']:
|
| 393 |
print(vorp_frame[vorp_frame['Pos'] == pos].head(20))
|
| 394 |
|
| 395 |
-
return pos_des_dict, orig_rank_dict, half_ppr_match_dict, custom_match_dict
|
| 396 |
|
| 397 |
-
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
|
| 398 |
|
| 399 |
vorp_frame = pd.DataFrame()
|
| 400 |
for positions in ['QB', 'RB', 'WR', 'TE']:
|
|
@@ -421,7 +420,6 @@ def assign_vorp_roster(frame: pd.DataFrame, halfPpr_rv: dict, custom_rv: dict, p
|
|
| 421 |
vorp_frame['custom_rank'] = vorp_frame['Rank_Adjust'].rank(method='first', ascending=True).astype(int)
|
| 422 |
vorp_frame['pos_rank'] = vorp_frame.groupby('Pos')['custom_rank'].rank(method='first', ascending=True).astype(int)
|
| 423 |
vorp_frame['pos_des'] = vorp_frame['Pos'] + vorp_frame['pos_rank'].astype(str)
|
| 424 |
-
vorp_frame['Name'] = vorp_frame['custom_lu'].map(match_back_dict)
|
| 425 |
|
| 426 |
return vorp_frame.sort_values(by='custom_rank', ascending=True)
|
| 427 |
|
|
@@ -452,6 +450,7 @@ def main():
|
|
| 452 |
final_df = assign_vorp_roster(position_df, halfPpr_rv, custom_roster_rv, user_pos_vorp_limiters, half_ppr_match_dict, custom_match_dict)
|
| 453 |
final_df = final_df.drop(columns=['SR_ID'], axis=1)
|
| 454 |
final_df['Name_Lookup'] = final_df['Name'].map(orig_rank_dict)
|
|
|
|
| 455 |
|
| 456 |
# Display results
|
| 457 |
st.header("Player Rankings")
|
|
|
|
| 387 |
orig_rank_dict = dict(zip(vorp_frame['Name'], vorp_frame['pos_designation']))
|
| 388 |
half_ppr_match_dict = dict(zip(vorp_frame['pos_designation'], vorp_frame['halfPpr']))
|
| 389 |
custom_match_dict = dict(zip(vorp_frame['pos_designation'], vorp_frame[rv_type]))
|
|
|
|
| 390 |
|
| 391 |
for pos in ['QB', 'RB', 'WR', 'TE']:
|
| 392 |
print(vorp_frame[vorp_frame['Pos'] == pos].head(20))
|
| 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']:
|
|
|
|
| 420 |
vorp_frame['custom_rank'] = vorp_frame['Rank_Adjust'].rank(method='first', ascending=True).astype(int)
|
| 421 |
vorp_frame['pos_rank'] = vorp_frame.groupby('Pos')['custom_rank'].rank(method='first', ascending=True).astype(int)
|
| 422 |
vorp_frame['pos_des'] = vorp_frame['Pos'] + vorp_frame['pos_rank'].astype(str)
|
|
|
|
| 423 |
|
| 424 |
return vorp_frame.sort_values(by='custom_rank', ascending=True)
|
| 425 |
|
|
|
|
| 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")
|