Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
st.set_page_config(layout="wide")
|
| 3 |
|
|
@@ -46,7 +88,7 @@ def init_baselines():
|
|
| 46 |
raw_display = raw_display[1:]
|
| 47 |
raw_display = raw_display.reset_index(drop=True)
|
| 48 |
gamelog_table = raw_display[raw_display['PLAYER_NAME'] != ""]
|
| 49 |
-
gamelog_table = gamelog_table[['PLAYER_NAME', 'TEAM_NAME', 'OPP_NAME', 'SEASON_ID', 'GAME_DATE', 'MATCHUP', 'MIN', 'touches', 'PTS', 'FGM', 'FGA', 'FG_PCT', 'FG3M', 'FG3A',
|
| 50 |
'FG3_PCT', 'FTM', 'FTA', 'FT_PCT', 'reboundChancesOffensive', 'OREB', 'reboundChancesDefensive', 'DREB', 'reboundChancesTotal', 'REB',
|
| 51 |
'passes', 'secondaryAssists', 'freeThrowAssists', 'assists', 'STL', 'BLK', 'TOV', 'PF', 'DD', 'TD', 'Fantasy', 'FD_Fantasy']]
|
| 52 |
gamelog_table['assists'].replace("", 0, inplace=True)
|
|
@@ -66,11 +108,11 @@ def init_baselines():
|
|
| 66 |
gamelog_table['assists_per_pass'] = gamelog_table['assists'] / gamelog_table['passes']
|
| 67 |
gamelog_table['Fantasy_per_touch'] = gamelog_table['Fantasy'] / gamelog_table['touches']
|
| 68 |
gamelog_table['FD_Fantasy_per_touch'] = gamelog_table['FD_Fantasy'] / gamelog_table['touches']
|
| 69 |
-
data_cols = gamelog_table.columns.drop(['PLAYER_NAME', 'TEAM_NAME', 'OPP_NAME', 'SEASON_ID', 'GAME_DATE', 'MATCHUP'])
|
| 70 |
gamelog_table[data_cols] = gamelog_table[data_cols].apply(pd.to_numeric, errors='coerce')
|
| 71 |
gamelog_table['GAME_DATE'] = pd.to_datetime(gamelog_table['GAME_DATE']).dt.date
|
| 72 |
|
| 73 |
-
gamelog_table = gamelog_table.set_axis(['Player', 'Team', 'Opp', 'Season', 'Date', 'Matchup', 'Min', 'Touches', 'Pts', 'FGM', 'FGA', 'FG%', 'FG3M', 'FG3A',
|
| 74 |
'FG3%', 'FTM', 'FTA', 'FT%', 'OREB Chance', 'OREB', 'DREB Chance', 'DREB', 'REB Chance', 'REB',
|
| 75 |
'Passes', 'Alt Assists', 'FT Assists', 'Assists', 'Stl', 'Blk', 'Tov', 'PF', 'DD', 'TD', 'Fantasy', 'FD_Fantasy',
|
| 76 |
'Rebound%', 'Assists/Pass', 'Fantasy/Touch', 'FD Fantasy/Touch'], axis=1)
|
|
@@ -79,7 +121,7 @@ def init_baselines():
|
|
| 79 |
|
| 80 |
@st.cache_data(show_spinner=False)
|
| 81 |
def seasonlong_build(data_sample):
|
| 82 |
-
season_long_table = data_sample[['Player', 'Team']]
|
| 83 |
season_long_table['Min'] = data_sample.groupby(['Player', 'Season'], sort=False)['Min'].transform('mean').astype(float)
|
| 84 |
season_long_table['Touches'] = data_sample.groupby(['Player', 'Season'], sort=False)['Touches'].transform('mean').astype(float)
|
| 85 |
season_long_table['Pts'] = data_sample.groupby(['Player', 'Season'], sort=False)['Pts'].transform('mean').astype(float)
|
|
@@ -125,7 +167,7 @@ def seasonlong_build(data_sample):
|
|
| 125 |
|
| 126 |
season_long_table = season_long_table.sort_values(by='Fantasy', ascending=False)
|
| 127 |
|
| 128 |
-
season_long_table = season_long_table.set_axis(['Player', 'Team', 'Min', 'Touches', 'Pts', 'FGM', 'FGA', 'FG%', 'FG3M', 'FG3A',
|
| 129 |
'FG3%', 'FTM', 'FTA', 'FT%', 'OREB Chance', 'OREB', 'DREB Chance', 'DREB', 'REB Chance', 'REB',
|
| 130 |
'Passes', 'Alt Assists', 'FT Assists', 'Assists', 'Stl', 'Blk', 'Tov', 'PF', 'DD', 'TD', 'Fantasy', 'FD_Fantasy',
|
| 131 |
'Rebound%', 'Assists/Pass', 'Fantasy/Touch', 'FD Fantasy/Touch'], axis=1)
|
|
@@ -329,4 +371,4 @@ with tab2:
|
|
| 329 |
corr_display = run_fantasy_corr(gamelog_table)
|
| 330 |
elif corr_var == 'Minutes':
|
| 331 |
corr_display = run_min_corr(gamelog_table)
|
| 332 |
-
display.dataframe(corr_display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
|
|
|
| 1 |
+
Hugging Face's logo
|
| 2 |
+
Hugging Face
|
| 3 |
+
Search models, datasets, users...
|
| 4 |
+
Models
|
| 5 |
+
Datasets
|
| 6 |
+
Spaces
|
| 7 |
+
Docs
|
| 8 |
+
Solutions
|
| 9 |
+
Pricing
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
Spaces:
|
| 14 |
+
|
| 15 |
+
Multichem
|
| 16 |
+
/
|
| 17 |
+
NBA_Gamelogs
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
like
|
| 21 |
+
0
|
| 22 |
+
|
| 23 |
+
Logs
|
| 24 |
+
App
|
| 25 |
+
Files
|
| 26 |
+
Community
|
| 27 |
+
Settings
|
| 28 |
+
NBA_Gamelogs
|
| 29 |
+
/
|
| 30 |
+
app.py
|
| 31 |
+
Multichem's picture
|
| 32 |
+
Multichem
|
| 33 |
+
Update app.py
|
| 34 |
+
0edd0c1
|
| 35 |
+
17 minutes ago
|
| 36 |
+
raw
|
| 37 |
+
history
|
| 38 |
+
blame
|
| 39 |
+
edit
|
| 40 |
+
delete
|
| 41 |
+
No virus
|
| 42 |
+
23.1 kB
|
| 43 |
import streamlit as st
|
| 44 |
st.set_page_config(layout="wide")
|
| 45 |
|
|
|
|
| 88 |
raw_display = raw_display[1:]
|
| 89 |
raw_display = raw_display.reset_index(drop=True)
|
| 90 |
gamelog_table = raw_display[raw_display['PLAYER_NAME'] != ""]
|
| 91 |
+
gamelog_table = gamelog_table[['PLAYER_NAME', 'POS', 'TEAM_NAME', 'OPP_NAME', 'SEASON_ID', 'GAME_DATE', 'MATCHUP', 'MIN', 'touches', 'PTS', 'FGM', 'FGA', 'FG_PCT', 'FG3M', 'FG3A',
|
| 92 |
'FG3_PCT', 'FTM', 'FTA', 'FT_PCT', 'reboundChancesOffensive', 'OREB', 'reboundChancesDefensive', 'DREB', 'reboundChancesTotal', 'REB',
|
| 93 |
'passes', 'secondaryAssists', 'freeThrowAssists', 'assists', 'STL', 'BLK', 'TOV', 'PF', 'DD', 'TD', 'Fantasy', 'FD_Fantasy']]
|
| 94 |
gamelog_table['assists'].replace("", 0, inplace=True)
|
|
|
|
| 108 |
gamelog_table['assists_per_pass'] = gamelog_table['assists'] / gamelog_table['passes']
|
| 109 |
gamelog_table['Fantasy_per_touch'] = gamelog_table['Fantasy'] / gamelog_table['touches']
|
| 110 |
gamelog_table['FD_Fantasy_per_touch'] = gamelog_table['FD_Fantasy'] / gamelog_table['touches']
|
| 111 |
+
data_cols = gamelog_table.columns.drop(['PLAYER_NAME', 'POS', 'TEAM_NAME', 'OPP_NAME', 'SEASON_ID', 'GAME_DATE', 'MATCHUP'])
|
| 112 |
gamelog_table[data_cols] = gamelog_table[data_cols].apply(pd.to_numeric, errors='coerce')
|
| 113 |
gamelog_table['GAME_DATE'] = pd.to_datetime(gamelog_table['GAME_DATE']).dt.date
|
| 114 |
|
| 115 |
+
gamelog_table = gamelog_table.set_axis(['Player', 'Pos', 'Team', 'Opp', 'Season', 'Date', 'Matchup', 'Min', 'Touches', 'Pts', 'FGM', 'FGA', 'FG%', 'FG3M', 'FG3A',
|
| 116 |
'FG3%', 'FTM', 'FTA', 'FT%', 'OREB Chance', 'OREB', 'DREB Chance', 'DREB', 'REB Chance', 'REB',
|
| 117 |
'Passes', 'Alt Assists', 'FT Assists', 'Assists', 'Stl', 'Blk', 'Tov', 'PF', 'DD', 'TD', 'Fantasy', 'FD_Fantasy',
|
| 118 |
'Rebound%', 'Assists/Pass', 'Fantasy/Touch', 'FD Fantasy/Touch'], axis=1)
|
|
|
|
| 121 |
|
| 122 |
@st.cache_data(show_spinner=False)
|
| 123 |
def seasonlong_build(data_sample):
|
| 124 |
+
season_long_table = data_sample[['Player', 'Pos', 'Team']]
|
| 125 |
season_long_table['Min'] = data_sample.groupby(['Player', 'Season'], sort=False)['Min'].transform('mean').astype(float)
|
| 126 |
season_long_table['Touches'] = data_sample.groupby(['Player', 'Season'], sort=False)['Touches'].transform('mean').astype(float)
|
| 127 |
season_long_table['Pts'] = data_sample.groupby(['Player', 'Season'], sort=False)['Pts'].transform('mean').astype(float)
|
|
|
|
| 167 |
|
| 168 |
season_long_table = season_long_table.sort_values(by='Fantasy', ascending=False)
|
| 169 |
|
| 170 |
+
season_long_table = season_long_table.set_axis(['Player', 'Pos', 'Team', 'Min', 'Touches', 'Pts', 'FGM', 'FGA', 'FG%', 'FG3M', 'FG3A',
|
| 171 |
'FG3%', 'FTM', 'FTA', 'FT%', 'OREB Chance', 'OREB', 'DREB Chance', 'DREB', 'REB Chance', 'REB',
|
| 172 |
'Passes', 'Alt Assists', 'FT Assists', 'Assists', 'Stl', 'Blk', 'Tov', 'PF', 'DD', 'TD', 'Fantasy', 'FD_Fantasy',
|
| 173 |
'Rebound%', 'Assists/Pass', 'Fantasy/Touch', 'FD Fantasy/Touch'], axis=1)
|
|
|
|
| 371 |
corr_display = run_fantasy_corr(gamelog_table)
|
| 372 |
elif corr_var == 'Minutes':
|
| 373 |
corr_display = run_min_corr(gamelog_table)
|
| 374 |
+
display.dataframe(corr_display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|