Spaces:
Running
Running
James McCool
commited on
Commit
·
abc57c8
1
Parent(s):
4e0ef71
Refactor VORP calculation in Streamlit app by removing unnecessary intermediate calculations and streamlining the ranking process, enhancing clarity and performance in player evaluations.
Browse files- src/streamlit_app.py +0 -20
src/streamlit_app.py
CHANGED
@@ -402,27 +402,11 @@ def assign_vorp_roster(frame: pd.DataFrame, halfPpr_rv: dict, custom_rv: dict, l
|
|
402 |
pos_frame = frame[frame['Pos'] == positions]
|
403 |
pos_frame = pos_frame[pos_frame['Rank'] != 0]
|
404 |
pos_frame = pos_frame.sort_values(by='Rank', ascending=True).reset_index(drop=True)
|
405 |
-
pos_frame['custom_rank_raw'] = pos_frame[rv_type].rank(method='first', ascending=False)
|
406 |
-
pos_frame['custom_calc'] = ((pos_frame['custom_rank_raw'] + pos_frame['Rank']) / 2).astype(int)
|
407 |
-
pos_frame['custom_proj_rank'] = pos_frame['custom_calc'].rank(method='first', ascending=True).astype(int)
|
408 |
-
|
409 |
-
pos_frame['max_halfPpr'] = pos_frame['halfPpr'].max()
|
410 |
-
pos_frame['halfPpr_range'] = (pos_frame['max_halfPpr']) / len(pos_frame)
|
411 |
-
pos_frame['adj_halfPpr'] = pos_frame['halfPpr_range'] * (len(pos_frame) - (pos_frame.index))
|
412 |
-
|
413 |
-
pos_frame['max_custom'] = pos_frame[rv_type].max()
|
414 |
-
pos_frame['custom_range'] = (pos_frame['max_custom']) / len(pos_frame)
|
415 |
-
pos_frame['adj_custom'] = pos_frame['custom_range'] * (len(pos_frame) - (pos_frame['custom_proj_rank'] - 1))
|
416 |
-
pos_frame['pos_lock'] = (pos_frame['Pos'].astype(str) + pos_frame['custom_proj_rank'].astype(str))
|
417 |
-
|
418 |
-
print(pos_frame[['Name', 'Rank', 'custom_proj_rank', 'halfPpr', rv_type, 'adj_halfPpr', 'adj_custom', 'pos_lock']].head(20))
|
419 |
|
420 |
pos_frame['halfPpr_rv'] = halfPpr_rv[positions]
|
421 |
pos_frame['custom_rv'] = custom_rv[positions]
|
422 |
pos_frame['halfPpr_VORP'] = pos_frame['halfPpr'] - halfPpr_rv[positions]
|
423 |
pos_frame['custom_VORP'] = pos_frame[rv_type] - custom_rv[positions]
|
424 |
-
|
425 |
-
pos_frame = pos_frame.drop(columns=['custom_rank_raw', 'custom_calc', 'custom_proj_rank', 'max_halfPpr', 'halfPpr_range', 'max_custom', 'custom_range'])
|
426 |
|
427 |
vorp_frame = pd.concat([vorp_frame, pos_frame]).reset_index(drop=True)
|
428 |
|
@@ -431,10 +415,6 @@ def assign_vorp_roster(frame: pd.DataFrame, halfPpr_rv: dict, custom_rv: dict, l
|
|
431 |
vorp_frame['vorp_diff'] = np.where(vorp_frame['halfPpr_VORP'] == vorp_frame['custom_VORP'], 0, vorp_frame['halfPpr_vorp_rank'] - vorp_frame['custom_vorp_rank'])
|
432 |
for positions in ['QB', 'RB', 'WR', 'TE']:
|
433 |
vorp_frame.loc[vorp_frame['Pos'] == positions, 'Rank_Adjust'] = (vorp_frame['Rank'] - (vorp_frame['vorp_diff'] * pos_vorp_limiters[positions])).astype(float)
|
434 |
-
if league_settings['TYPE'] == 'Standard':
|
435 |
-
vorp_frame.loc[vorp_frame['Pos'] == 'QB', 'Rank_Adjust'] = vorp_frame.loc[vorp_frame['Pos'] == 'QB', 'Rank_Adjust'].apply(lambda x: max(x, 10))
|
436 |
-
elif league_settings['TYPE'] == 'PPR':
|
437 |
-
vorp_frame.loc[vorp_frame['Pos'] == 'QB', 'Rank_Adjust'] = vorp_frame.loc[vorp_frame['Pos'] == 'QB', 'Rank_Adjust'].apply(lambda x: max(x, -10))
|
438 |
pos_lock_dict = dict(zip(vorp_frame['pos_lock'], vorp_frame['Name']))
|
439 |
name_lock_dict = dict(zip(vorp_frame['Name'], vorp_frame['pos_lock']))
|
440 |
vorp_frame['custom_rank'] = vorp_frame['Rank_Adjust'].rank(method='first', ascending=True).astype(int)
|
|
|
402 |
pos_frame = frame[frame['Pos'] == positions]
|
403 |
pos_frame = pos_frame[pos_frame['Rank'] != 0]
|
404 |
pos_frame = pos_frame.sort_values(by='Rank', ascending=True).reset_index(drop=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
|
406 |
pos_frame['halfPpr_rv'] = halfPpr_rv[positions]
|
407 |
pos_frame['custom_rv'] = custom_rv[positions]
|
408 |
pos_frame['halfPpr_VORP'] = pos_frame['halfPpr'] - halfPpr_rv[positions]
|
409 |
pos_frame['custom_VORP'] = pos_frame[rv_type] - custom_rv[positions]
|
|
|
|
|
410 |
|
411 |
vorp_frame = pd.concat([vorp_frame, pos_frame]).reset_index(drop=True)
|
412 |
|
|
|
415 |
vorp_frame['vorp_diff'] = np.where(vorp_frame['halfPpr_VORP'] == vorp_frame['custom_VORP'], 0, vorp_frame['halfPpr_vorp_rank'] - vorp_frame['custom_vorp_rank'])
|
416 |
for positions in ['QB', 'RB', 'WR', 'TE']:
|
417 |
vorp_frame.loc[vorp_frame['Pos'] == positions, 'Rank_Adjust'] = (vorp_frame['Rank'] - (vorp_frame['vorp_diff'] * pos_vorp_limiters[positions])).astype(float)
|
|
|
|
|
|
|
|
|
418 |
pos_lock_dict = dict(zip(vorp_frame['pos_lock'], vorp_frame['Name']))
|
419 |
name_lock_dict = dict(zip(vorp_frame['Name'], vorp_frame['pos_lock']))
|
420 |
vorp_frame['custom_rank'] = vorp_frame['Rank_Adjust'].rank(method='first', ascending=True).astype(int)
|