James McCool commited on
Commit
5857274
·
1 Parent(s): 253ecef

Refactor variable names in VORP roster assignment within Streamlit app for improved clarity and consistency, updating halfPPR and custom lookup variables and ensuring accurate calculations of VORP values.

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +7 -7
src/streamlit_app.py CHANGED
@@ -396,14 +396,14 @@ def assign_vorp_roster(frame: pd.DataFrame, halfPpr_rv: dict, custom_rv: dict, p
396
  pos_frame = pos_frame[pos_frame['Rank'] != 0]
397
  pos_frame = pos_frame.sort_values(by='Rank', ascending=True).reset_index(drop=True)
398
  pos_frame['ranker_rank'] = pos_frame['Rank'].rank(method='first', ascending=True).astype(int)
399
- pos_frame['pos_rank_initial'] = pos_frame['Pos'] + pos_frame['ranker_rank'].astype(str)
400
- pos_frame['halfPpr_lookup'] = pos_frame['pos_rank_initial'].map(half_ppr_match_dict)
401
- pos_frame['custom_lookup'] = pos_frame['pos_rank_initial'].map(custom_match_dict)
402
 
403
  pos_frame['halfPpr_rv'] = halfPpr_rv[positions]
404
  pos_frame['custom_rv'] = custom_rv[positions]
405
- pos_frame['halfPpr_VORP'] = pos_frame['halfPpr_lookup'] - pos_frame['halfPpr_rv']
406
- pos_frame['custom_VORP'] = pos_frame['custom_lookup'] - pos_frame['custom_rv']
407
 
408
  vorp_frame = pd.concat([vorp_frame, pos_frame]).reset_index(drop=True)
409
 
@@ -414,7 +414,7 @@ def assign_vorp_roster(frame: pd.DataFrame, halfPpr_rv: dict, custom_rv: dict, p
414
  vorp_frame.loc[vorp_frame['Pos'] == positions, 'Rank_Adjust'] = (vorp_frame['Rank'] - (vorp_frame['vorp_diff'] * pos_vorp_limiters[positions])).astype(float)
415
  vorp_frame['custom_rank'] = vorp_frame['Rank_Adjust'].rank(method='first', ascending=True).astype(int)
416
  vorp_frame['pos_rank'] = vorp_frame.groupby('Pos')['custom_rank'].rank(method='first', ascending=True).astype(int)
417
- vorp_frame['pos_designation'] = vorp_frame['Pos'] + vorp_frame['pos_rank'].astype(str)
418
 
419
  return vorp_frame.sort_values(by='custom_rank', ascending=True)
420
 
@@ -445,7 +445,7 @@ def main():
445
  final_df = assign_vorp_roster(position_df, halfPpr_rv, custom_roster_rv, user_pos_vorp_limiters, half_ppr_match_dict, custom_match_dict)
446
  final_df = final_df.drop(columns=['SR_ID'], axis=1)
447
  final_df['Name_Lookup'] = final_df['Name'].map(orig_rank_dict)
448
- final_df['Scoring_Lookup'] = final_df['pos_designation'].map(pos_des_dict)
449
 
450
  # Display results
451
  st.header("Player Rankings")
 
396
  pos_frame = pos_frame[pos_frame['Rank'] != 0]
397
  pos_frame = pos_frame.sort_values(by='Rank', ascending=True).reset_index(drop=True)
398
  pos_frame['ranker_rank'] = pos_frame['Rank'].rank(method='first', ascending=True).astype(int)
399
+ pos_frame['pos_rank_init'] = pos_frame['Pos'] + pos_frame['ranker_rank'].astype(str)
400
+ pos_frame['halfPpr_lu'] = pos_frame['pos_rank_init'].map(half_ppr_match_dict)
401
+ pos_frame['custom_lu'] = pos_frame['pos_rank_init'].map(custom_match_dict)
402
 
403
  pos_frame['halfPpr_rv'] = halfPpr_rv[positions]
404
  pos_frame['custom_rv'] = custom_rv[positions]
405
+ pos_frame['halfPpr_VORP'] = pos_frame['halfPpr_lu'] - pos_frame['halfPpr_rv']
406
+ pos_frame['custom_VORP'] = pos_frame['custom_lu'] - pos_frame['custom_rv']
407
 
408
  vorp_frame = pd.concat([vorp_frame, pos_frame]).reset_index(drop=True)
409
 
 
414
  vorp_frame.loc[vorp_frame['Pos'] == positions, 'Rank_Adjust'] = (vorp_frame['Rank'] - (vorp_frame['vorp_diff'] * pos_vorp_limiters[positions])).astype(float)
415
  vorp_frame['custom_rank'] = vorp_frame['Rank_Adjust'].rank(method='first', ascending=True).astype(int)
416
  vorp_frame['pos_rank'] = vorp_frame.groupby('Pos')['custom_rank'].rank(method='first', ascending=True).astype(int)
417
+ vorp_frame['pos_des'] = vorp_frame['Pos'] + vorp_frame['pos_rank'].astype(str)
418
 
419
  return vorp_frame.sort_values(by='custom_rank', ascending=True)
420
 
 
445
  final_df = assign_vorp_roster(position_df, halfPpr_rv, custom_roster_rv, user_pos_vorp_limiters, half_ppr_match_dict, custom_match_dict)
446
  final_df = final_df.drop(columns=['SR_ID'], axis=1)
447
  final_df['Name_Lookup'] = final_df['Name'].map(orig_rank_dict)
448
+ final_df['Scoring_Lookup'] = final_df['pos_des'].map(pos_des_dict)
449
 
450
  # Display results
451
  st.header("Player Rankings")