James McCool
commited on
Commit
·
265891c
1
Parent(s):
5fe15cf
adjusting stacking sports logic
Browse files
app.py
CHANGED
|
@@ -30,7 +30,8 @@ from global_func.reassess_edge import reassess_edge
|
|
| 30 |
|
| 31 |
freq_format = {'Finish_percentile': '{:.2%}', 'Lineup Edge': '{:.2%}', 'Win%': '{:.2%}'}
|
| 32 |
stacking_sports = ['MLB', 'NHL', 'NFL', 'LOL', 'NCAAF']
|
| 33 |
-
all_column_stack_sports = ['LOL', 'NCAAF', 'WNBA', 'NBA', 'CS2']
|
|
|
|
| 34 |
player_wrong_names_mlb = ['Enrique Hernandez', 'Joseph Cantillo', 'Mike Soroka', 'Jakob Bauers', 'Temi Fágbénlé']
|
| 35 |
player_right_names_mlb = ['Kike Hernandez', 'Joey Cantillo', 'Michael Soroka', 'Jake Bauers', 'Temi Fagbenle']
|
| 36 |
|
|
@@ -441,39 +442,24 @@ if selected_tab == 'Data Load':
|
|
| 441 |
# Update projections with matched names
|
| 442 |
projections['player_names'] = projections['player_names'].map(lambda x: projections_match_dict.get(x, x))
|
| 443 |
st.session_state['projections_df'] = projections
|
|
|
|
| 444 |
|
| 445 |
if sport_var in stacking_sports:
|
| 446 |
team_dict = dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['team']))
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
)
|
| 462 |
-
else:
|
| 463 |
-
st.session_state['portfolio']['Stack'] = st.session_state['portfolio'].apply(
|
| 464 |
-
lambda row: Counter(
|
| 465 |
-
team_dict.get(player, '') for player in row[2:]
|
| 466 |
-
if team_dict.get(player, '') != ''
|
| 467 |
-
).most_common(1)[0][0] if any(team_dict.get(player, '') for player in row[2:]) else '',
|
| 468 |
-
axis=1
|
| 469 |
-
)
|
| 470 |
-
st.session_state['portfolio']['Size'] = st.session_state['portfolio'].apply(
|
| 471 |
-
lambda row: Counter(
|
| 472 |
-
team_dict.get(player, '') for player in row[2:]
|
| 473 |
-
if team_dict.get(player, '') != ''
|
| 474 |
-
).most_common(1)[0][1] if any(team_dict.get(player, '') for player in row[2:]) else 0,
|
| 475 |
-
axis=1
|
| 476 |
-
)
|
| 477 |
st.session_state['stack_dict'] = dict(zip(st.session_state['portfolio'].index, st.session_state['portfolio']['Stack']))
|
| 478 |
st.session_state['size_dict'] = dict(zip(st.session_state['portfolio'].index, st.session_state['portfolio']['Size']))
|
| 479 |
|
|
|
|
| 30 |
|
| 31 |
freq_format = {'Finish_percentile': '{:.2%}', 'Lineup Edge': '{:.2%}', 'Win%': '{:.2%}'}
|
| 32 |
stacking_sports = ['MLB', 'NHL', 'NFL', 'LOL', 'NCAAF']
|
| 33 |
+
# all_column_stack_sports = ['LOL', 'NCAAF', 'WNBA', 'NBA', 'CS2']
|
| 34 |
+
exclude_stacks = ['BaseName', 'EntryCount', 'SP', 'SP1', 'SP2', 'P1', 'P2', 'RB1', 'RB2', 'DST', 'G']
|
| 35 |
player_wrong_names_mlb = ['Enrique Hernandez', 'Joseph Cantillo', 'Mike Soroka', 'Jakob Bauers', 'Temi Fágbénlé']
|
| 36 |
player_right_names_mlb = ['Kike Hernandez', 'Joey Cantillo', 'Michael Soroka', 'Jake Bauers', 'Temi Fagbenle']
|
| 37 |
|
|
|
|
| 442 |
# Update projections with matched names
|
| 443 |
projections['player_names'] = projections['player_names'].map(lambda x: projections_match_dict.get(x, x))
|
| 444 |
st.session_state['projections_df'] = projections
|
| 445 |
+
st.session_state['stack_columns'] = [col for col in st.session_state['portfolio'].columns if col not in exclude_stacks]
|
| 446 |
|
| 447 |
if sport_var in stacking_sports:
|
| 448 |
team_dict = dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['team']))
|
| 449 |
+
st.session_state['portfolio']['Stack'] = st.session_state['portfolio'].apply(
|
| 450 |
+
lambda row: Counter(
|
| 451 |
+
team_dict.get(player, '') for player in row[st.session_state['stack_columns']]
|
| 452 |
+
if team_dict.get(player, '') != ''
|
| 453 |
+
).most_common(1)[0][0] if any(team_dict.get(player, '') for player in row[st.session_state['stack_columns']]) else '',
|
| 454 |
+
axis=1
|
| 455 |
+
)
|
| 456 |
+
st.session_state['portfolio']['Size'] = st.session_state['portfolio'].apply(
|
| 457 |
+
lambda row: Counter(
|
| 458 |
+
team_dict.get(player, '') for player in row[st.session_state['stack_columns']]
|
| 459 |
+
if team_dict.get(player, '') != ''
|
| 460 |
+
).most_common(1)[0][1] if any(team_dict.get(player, '') for player in row[st.session_state['stack_columns']]) else 0,
|
| 461 |
+
axis=1
|
| 462 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 463 |
st.session_state['stack_dict'] = dict(zip(st.session_state['portfolio'].index, st.session_state['portfolio']['Stack']))
|
| 464 |
st.session_state['size_dict'] = dict(zip(st.session_state['portfolio'].index, st.session_state['portfolio']['Size']))
|
| 465 |
|