Spaces:
Sleeping
Sleeping
James McCool
commited on
Commit
·
847a8a4
1
Parent(s):
8ba448c
Add match_back_dict to VORP scoring and roster assignment functions in Streamlit app for improved player name lookup, enhancing accuracy in player evaluations and ensuring consistent mapping of scoring data.
Browse files- src/streamlit_app.py +4 -3
src/streamlit_app.py
CHANGED
@@ -387,13 +387,14 @@ 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 |
|
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,6 +421,7 @@ def assign_vorp_roster(frame: pd.DataFrame, halfPpr_rv: dict, custom_rv: dict, p
|
|
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,7 +452,6 @@ def main():
|
|
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['Scoring_Lookup'] = final_df['pos_des'].map(pos_des_dict)
|
454 |
|
455 |
# Display results
|
456 |
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 |
+
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, match_back_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, match_back_dict: dict) -> pd.DataFrame:
|
398 |
|
399 |
vorp_frame = pd.DataFrame()
|
400 |
for positions in ['QB', 'RB', 'WR', 'TE']:
|
|
|
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['Scoring_Lookup'] = vorp_frame['custom_lu'].map(match_back_dict)
|
425 |
|
426 |
return vorp_frame.sort_values(by='custom_rank', ascending=True)
|
427 |
|
|
|
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")
|