Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import numpy as np
|
2 |
import pandas as pd
|
3 |
import streamlit as st
|
4 |
import gspread
|
5 |
|
6 |
-
st.set_page_config(layout="wide")
|
7 |
-
|
8 |
@st.cache_resource
|
9 |
def init_conn():
|
10 |
scope = ['https://www.googleapis.com/auth/spreadsheets',
|
@@ -28,65 +33,43 @@ def init_conn():
|
|
28 |
|
29 |
gcservice_account = init_conn()
|
30 |
|
|
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
right_acro = ['WAS', 'ARI']
|
35 |
-
|
36 |
-
game_format = {'Win Percentage': '{:.2%}','First Inning Lead Percentage': '{:.2%}',
|
37 |
-
'Fifth Inning Lead Percentage': '{:.2%}', '8+ runs': '{:.2%}', 'DK LevX': '{:.2%}', 'FD LevX': '{:.2%}'}
|
38 |
-
|
39 |
-
team_roo_format = {'Top Score%': '{:.2%}','0 Runs': '{:.2%}', '1 Run': '{:.2%}', '2 Runs': '{:.2%}', '3 Runs': '{:.2%}', '4 Runs': '{:.2%}',
|
40 |
-
'5 Runs': '{:.2%}','6 Runs': '{:.2%}', '7 Runs': '{:.2%}', '8 Runs': '{:.2%}', '9 Runs': '{:.2%}', '10 Runs': '{:.2%}'}
|
41 |
-
|
42 |
-
player_roo_format = {'Top_finish': '{:.2%}','Top_5_finish': '{:.2%}', 'Top_10_finish': '{:.2%}', '20+%': '{:.2%}', '2x%': '{:.2%}', '3x%': '{:.2%}',
|
43 |
-
'4x%': '{:.2%}','GPP%': '{:.2%}'}
|
44 |
-
|
45 |
-
all_dk_player_projections = 'https://docs.google.com/spreadsheets/d/1I_1Ve3F4tftgfLQQoRKOJ351XfEG48s36OxXUKxmgS8/edit#gid=1391856348'
|
46 |
-
|
47 |
-
@st.cache_resource(ttl = 600)
|
48 |
-
def player_stat_table():
|
49 |
sh = gcservice_account.open_by_url(all_dk_player_projections)
|
50 |
-
worksheet = sh.worksheet('
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
raw_display =
|
56 |
-
|
|
|
57 |
|
58 |
-
worksheet = sh.worksheet('
|
59 |
-
|
60 |
-
raw_display =
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
dk_roo_raw = load_display.dropna(subset=['Median'])
|
67 |
-
|
68 |
-
worksheet = sh.worksheet('FD_ROO')
|
69 |
-
load_display = pd.DataFrame(worksheet.get_all_records())
|
70 |
-
load_display.replace('', np.nan, inplace=True)
|
71 |
-
fd_roo_raw = load_display.dropna(subset=['Median'])
|
72 |
-
|
73 |
-
worksheet = sh.worksheet('Site_Info')
|
74 |
-
site_slates = pd.DataFrame(worksheet.get_all_records())
|
75 |
|
76 |
-
return
|
77 |
|
78 |
@st.cache_data
|
79 |
def convert_df_to_csv(df):
|
80 |
return df.to_csv().encode('utf-8')
|
81 |
|
82 |
-
|
83 |
-
opp_dict = dict(zip(
|
84 |
-
t_stamp =
|
85 |
|
86 |
tab1, tab2 = st.tabs(['Uploads and Info', 'Pivot Finder'])
|
87 |
|
88 |
with tab1:
|
89 |
-
st.info("The Projections file can have any columns in any order, but must contain columns explicitly named: 'Player', 'Salary', 'Position', 'Team', 'Opp', 'Median',
|
90 |
col1, col2 = st.columns([1, 5])
|
91 |
|
92 |
with col1:
|
@@ -102,36 +85,36 @@ with tab1:
|
|
102 |
st.dataframe(proj_dataframe.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
103 |
|
104 |
with tab2:
|
105 |
-
col1, col2 = st.columns([1,
|
106 |
with col1:
|
107 |
st.info(t_stamp)
|
108 |
if st.button("Load/Reset Data", key='reset1'):
|
109 |
st.cache_data.clear()
|
110 |
-
|
111 |
-
opp_dict = dict(zip(
|
112 |
-
t_stamp =
|
|
|
|
|
113 |
data_var1 = st.radio("Which data are you loading?", ('Paydirt', 'User'), key='data_var1')
|
114 |
site_var1 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'), key='site_var1')
|
115 |
if site_var1 == 'Draftkings':
|
116 |
if data_var1 == 'User':
|
117 |
raw_baselines = proj_dataframe
|
118 |
elif data_var1 != 'User':
|
119 |
-
raw_baselines =
|
120 |
-
raw_baselines = raw_baselines[raw_baselines['version'] == 'overall']
|
121 |
elif site_var1 == 'Fanduel':
|
122 |
if data_var1 == 'User':
|
123 |
raw_baselines = proj_dataframe
|
124 |
elif data_var1 != 'User':
|
125 |
-
raw_baselines =
|
126 |
-
|
127 |
-
player_check = st.selectbox('Select player to create comps', options = dk_roo_raw['Player'].unique(), key='dk_player')
|
128 |
Salary_var = st.number_input('Acceptable +/- Salary range', min_value = 0, max_value = 1000, value = 300, step = 100)
|
129 |
Median_var = st.number_input('Acceptable +/- Median range', min_value = 0, max_value = 10, value = 3, step = 1)
|
130 |
pos_var1 = st.radio("Compare to all positions or specific positions?", ('All Positions', 'Specific Positions'), key='pos_var1')
|
131 |
if pos_var1 == 'Specific Positions':
|
132 |
-
pos_var_list = st.multiselect('Which positions would you like to include?', options =
|
133 |
elif pos_var1 == 'All Positions':
|
134 |
-
pos_var_list =
|
135 |
split_var1 = st.radio("Are you running the full slate or certain games?", ('Full Slate Run', 'Specific Games'), key='split_var1')
|
136 |
if split_var1 == 'Specific Games':
|
137 |
team_var1 = st.multiselect('Which teams would you like to include?', options = raw_baselines['Team'].unique(), key='team_var1')
|
@@ -139,20 +122,21 @@ with tab2:
|
|
139 |
team_var1 = raw_baselines.Team.values.tolist()
|
140 |
|
141 |
with col2:
|
|
|
|
|
142 |
hold_container = st.empty()
|
143 |
if st.button('Simulate appropriate pivots'):
|
144 |
with hold_container:
|
145 |
if site_var1 == 'Draftkings':
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
own_dict = dict(zip(working_roo.Player, working_roo.Own))
|
|
|
154 |
team_dict = dict(zip(working_roo.Player, working_roo.Team))
|
155 |
-
opp_dict = dict(zip(working_roo.Player, working_roo.Opp))
|
156 |
total_sims = 1000
|
157 |
|
158 |
player_var = working_roo.loc[working_roo['Player'] == player_check]
|
@@ -163,14 +147,10 @@ with tab2:
|
|
163 |
working_roo = working_roo.loc[(working_roo['Salary'] >= player_var['Salary'][0] - Salary_var) & (working_roo['Salary'] <= player_var['Salary'][0] + Salary_var)]
|
164 |
working_roo = working_roo.loc[(working_roo['Median'] >= player_var['Median'][0] - Median_var) & (working_roo['Median'] <= player_var['Median'][0] + Median_var)]
|
165 |
|
166 |
-
flex_file = working_roo[['Player', 'Position', 'Salary', 'Median']]
|
167 |
-
flex_file['
|
168 |
-
flex_file['
|
169 |
-
flex_file['
|
170 |
-
flex_file['Floor'] = np.where(flex_file['Position'] == 'RB', (flex_file['Median'] * .15), flex_file['Floor_raw'])
|
171 |
-
flex_file['Ceiling'] = np.where(flex_file['Position'] == 'QB', (flex_file['Median'] * 1.75), flex_file['Ceiling_raw'])
|
172 |
-
flex_file['Ceiling'] = np.where(flex_file['Position'] == 'RB', (flex_file['Median'] * 1.85), flex_file['Ceiling_raw'])
|
173 |
-
flex_file['STD'] = flex_file['Median'] / 4
|
174 |
flex_file = flex_file[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD']]
|
175 |
hold_file = flex_file
|
176 |
overall_file = flex_file
|
@@ -202,51 +182,59 @@ with tab2:
|
|
202 |
|
203 |
players_only=players_only.drop(['Player'], axis=1)
|
204 |
players_only.astype('int').dtypes
|
205 |
-
|
206 |
-
salary_2x_check = (overall_file - (salary_file*
|
207 |
-
salary_3x_check = (overall_file - (salary_file*
|
208 |
-
salary_4x_check = (overall_file - (salary_file*
|
209 |
-
|
|
|
210 |
players_only['Average_Rank'] = players_only.mean(axis=1)
|
211 |
players_only['Top_finish'] = players_only[players_only == 1].count(axis=1)/total_sims
|
212 |
players_only['Top_5_finish'] = players_only[players_only <= 5].count(axis=1)/total_sims
|
213 |
players_only['Top_10_finish'] = players_only[players_only <= 10].count(axis=1)/total_sims
|
214 |
players_only['20+%'] = overall_file[overall_file >= 20].count(axis=1)/float(total_sims)
|
215 |
-
players_only['
|
216 |
-
players_only['
|
217 |
-
players_only['
|
218 |
-
|
|
|
219 |
players_only['Player'] = hold_file[['Player']]
|
220 |
-
|
221 |
-
final_outcomes = players_only[['Player', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '
|
222 |
|
223 |
final_Proj = pd.merge(hold_file, final_outcomes, on="Player")
|
224 |
-
final_Proj = final_Proj[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '
|
|
|
225 |
final_Proj['Own'] = final_Proj['Player'].map(own_dict)
|
|
|
226 |
final_Proj['Team'] = final_Proj['Player'].map(team_dict)
|
227 |
-
final_Proj['
|
228 |
-
final_Proj = final_Proj[['
|
229 |
-
final_Proj['
|
230 |
-
|
231 |
-
final_Proj['LevX']
|
232 |
-
final_Proj['LevX'] = np.where(final_Proj['Position'] == 'QB', final_Proj[['Projection Rank', 'Top_5_finish']].mean(axis=1) + final_Proj['4x%'] - final_Proj['Own Rank'], final_Proj['LevX'])
|
233 |
-
final_Proj['LevX'] = np.where(final_Proj['Position'] == 'TE', final_Proj[['Projection Rank', '2x%']].mean(axis=1) + final_Proj['4x%'] - final_Proj['Own Rank'], final_Proj['LevX'])
|
234 |
-
final_Proj['LevX'] = np.where(final_Proj['Position'] == 'RB', final_Proj[['Projection Rank', 'Top_5_finish']].mean(axis=1) + final_Proj['20+%'] - final_Proj['Own Rank'], final_Proj['LevX'])
|
235 |
-
final_Proj['LevX'] = np.where(final_Proj['Position'] == 'WR', final_Proj[['Projection Rank', 'Top_10_finish']].mean(axis=1) + final_Proj['4x%'] - final_Proj['Own Rank'], final_Proj['LevX'])
|
236 |
-
final_Proj['CPT_Own'] = final_Proj['Own'] / 4
|
237 |
-
|
238 |
-
final_Proj = final_Proj[['Player', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%', 'Own', 'LevX']]
|
239 |
final_Proj = final_Proj.set_index('Player')
|
240 |
-
final_Proj = final_Proj.sort_values(by='
|
241 |
-
|
242 |
-
|
|
|
243 |
hold_container = st.empty()
|
244 |
-
final_Proj = final_Proj
|
245 |
-
st.dataframe(final_Proj.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(player_roo_format, precision=2), use_container_width = True)
|
246 |
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
st.set_page_config(layout="wide")
|
3 |
+
|
4 |
+
for name in dir():
|
5 |
+
if not name.startswith('_'):
|
6 |
+
del globals()[name]
|
7 |
+
|
8 |
import numpy as np
|
9 |
import pandas as pd
|
10 |
import streamlit as st
|
11 |
import gspread
|
12 |
|
|
|
|
|
13 |
@st.cache_resource
|
14 |
def init_conn():
|
15 |
scope = ['https://www.googleapis.com/auth/spreadsheets',
|
|
|
33 |
|
34 |
gcservice_account = init_conn()
|
35 |
|
36 |
+
all_dk_player_projections = 'https://docs.google.com/spreadsheets/d/1Yq0vGriWK-bS79e-bD6_u9pqrYE6Yrlbb_wEkmH-ot0/edit#gid=172632260'
|
37 |
|
38 |
+
@st.cache_resource(ttl = 300)
|
39 |
+
def init_stat_load():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
sh = gcservice_account.open_by_url(all_dk_player_projections)
|
41 |
+
worksheet = sh.worksheet('DK_Build_Up')
|
42 |
+
raw_display = pd.DataFrame(worksheet.get_all_records())
|
43 |
+
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
|
44 |
+
raw_display.replace("", 'Welp', inplace=True)
|
45 |
+
raw_display = raw_display.loc[raw_display['Player'] != 'Welp']
|
46 |
+
raw_display = raw_display.loc[raw_display['Median'] > 0]
|
47 |
+
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
|
48 |
+
dk_raw = raw_display.sort_values(by='Median', ascending=False)
|
49 |
|
50 |
+
worksheet = sh.worksheet('FD_Build_Up')
|
51 |
+
raw_display = pd.DataFrame(worksheet.get_all_records())
|
52 |
+
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
|
53 |
+
raw_display.replace("", 'Welp', inplace=True)
|
54 |
+
raw_display = raw_display.loc[raw_display['Player'] != 'Welp']
|
55 |
+
raw_display = raw_display.loc[raw_display['Median'] > 0]
|
56 |
+
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
|
57 |
+
fd_raw = raw_display.sort_values(by='Median', ascending=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
+
return dk_raw, fd_raw
|
60 |
|
61 |
@st.cache_data
|
62 |
def convert_df_to_csv(df):
|
63 |
return df.to_csv().encode('utf-8')
|
64 |
|
65 |
+
dk_raw, fd_raw = init_stat_load()
|
66 |
+
opp_dict = dict(zip(dk_raw.Team, dk_raw.Opp))
|
67 |
+
t_stamp = "Fix this later"
|
68 |
|
69 |
tab1, tab2 = st.tabs(['Uploads and Info', 'Pivot Finder'])
|
70 |
|
71 |
with tab1:
|
72 |
+
st.info("The Projections file can have any columns in any order, but must contain columns explicitly named: 'Player', 'Salary', 'Position', 'Team', 'Opp', 'Minutes', 'Median', 'Own'.")
|
73 |
col1, col2 = st.columns([1, 5])
|
74 |
|
75 |
with col1:
|
|
|
85 |
st.dataframe(proj_dataframe.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
86 |
|
87 |
with tab2:
|
88 |
+
col1, col2 = st.columns([1, 9])
|
89 |
with col1:
|
90 |
st.info(t_stamp)
|
91 |
if st.button("Load/Reset Data", key='reset1'):
|
92 |
st.cache_data.clear()
|
93 |
+
dk_raw, fd_raw = init_stat_load()
|
94 |
+
opp_dict = dict(zip(dk_raw.Team, dk_raw.Opp))
|
95 |
+
t_stamp = "Fix this later"
|
96 |
+
for key in st.session_state.keys():
|
97 |
+
del st.session_state[key]
|
98 |
data_var1 = st.radio("Which data are you loading?", ('Paydirt', 'User'), key='data_var1')
|
99 |
site_var1 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'), key='site_var1')
|
100 |
if site_var1 == 'Draftkings':
|
101 |
if data_var1 == 'User':
|
102 |
raw_baselines = proj_dataframe
|
103 |
elif data_var1 != 'User':
|
104 |
+
raw_baselines = dk_raw
|
|
|
105 |
elif site_var1 == 'Fanduel':
|
106 |
if data_var1 == 'User':
|
107 |
raw_baselines = proj_dataframe
|
108 |
elif data_var1 != 'User':
|
109 |
+
raw_baselines = fd_raw
|
110 |
+
player_check = st.selectbox('Select player to create comps', options = dk_raw['Player'].unique(), key='dk_player')
|
|
|
111 |
Salary_var = st.number_input('Acceptable +/- Salary range', min_value = 0, max_value = 1000, value = 300, step = 100)
|
112 |
Median_var = st.number_input('Acceptable +/- Median range', min_value = 0, max_value = 10, value = 3, step = 1)
|
113 |
pos_var1 = st.radio("Compare to all positions or specific positions?", ('All Positions', 'Specific Positions'), key='pos_var1')
|
114 |
if pos_var1 == 'Specific Positions':
|
115 |
+
pos_var_list = st.multiselect('Which positions would you like to include?', options = ['PG', 'SG', 'SF', 'PF', 'C'], key='pos_var_list')
|
116 |
elif pos_var1 == 'All Positions':
|
117 |
+
pos_var_list = ['PG', 'SG', 'SF', 'PF', 'C']
|
118 |
split_var1 = st.radio("Are you running the full slate or certain games?", ('Full Slate Run', 'Specific Games'), key='split_var1')
|
119 |
if split_var1 == 'Specific Games':
|
120 |
team_var1 = st.multiselect('Which teams would you like to include?', options = raw_baselines['Team'].unique(), key='team_var1')
|
|
|
122 |
team_var1 = raw_baselines.Team.values.tolist()
|
123 |
|
124 |
with col2:
|
125 |
+
display_container = st.empty()
|
126 |
+
display_dl_container = st.empty()
|
127 |
hold_container = st.empty()
|
128 |
if st.button('Simulate appropriate pivots'):
|
129 |
with hold_container:
|
130 |
if site_var1 == 'Draftkings':
|
131 |
+
raw_baselines = dk_raw
|
132 |
+
elif site_var1 == 'Fanduel':
|
133 |
+
raw_baselines = fd_raw
|
134 |
+
|
135 |
+
working_roo = raw_baselines
|
136 |
+
working_roo = working_roo[working_roo['Team'].isin(team_var1)]
|
|
|
137 |
own_dict = dict(zip(working_roo.Player, working_roo.Own))
|
138 |
+
min_dict = dict(zip(working_roo.Player, working_roo.Minutes))
|
139 |
team_dict = dict(zip(working_roo.Player, working_roo.Team))
|
|
|
140 |
total_sims = 1000
|
141 |
|
142 |
player_var = working_roo.loc[working_roo['Player'] == player_check]
|
|
|
147 |
working_roo = working_roo.loc[(working_roo['Salary'] >= player_var['Salary'][0] - Salary_var) & (working_roo['Salary'] <= player_var['Salary'][0] + Salary_var)]
|
148 |
working_roo = working_roo.loc[(working_roo['Median'] >= player_var['Median'][0] - Median_var) & (working_roo['Median'] <= player_var['Median'][0] + Median_var)]
|
149 |
|
150 |
+
flex_file = working_roo[['Player', 'Position', 'Salary', 'Median', 'Minutes']]
|
151 |
+
flex_file['Floor'] = (flex_file['Median'] * .25) + (flex_file['Minutes'] * .25)
|
152 |
+
flex_file['Ceiling'] = flex_file['Median'] + 10 + (flex_file['Minutes'] * .25)
|
153 |
+
flex_file['STD'] = (flex_file['Median']/4)
|
|
|
|
|
|
|
|
|
154 |
flex_file = flex_file[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD']]
|
155 |
hold_file = flex_file
|
156 |
overall_file = flex_file
|
|
|
182 |
|
183 |
players_only=players_only.drop(['Player'], axis=1)
|
184 |
players_only.astype('int').dtypes
|
185 |
+
|
186 |
+
salary_2x_check = (overall_file - (salary_file*4))
|
187 |
+
salary_3x_check = (overall_file - (salary_file*5))
|
188 |
+
salary_4x_check = (overall_file - (salary_file*6))
|
189 |
+
gpp_check = (overall_file - ((salary_file*5)+10))
|
190 |
+
|
191 |
players_only['Average_Rank'] = players_only.mean(axis=1)
|
192 |
players_only['Top_finish'] = players_only[players_only == 1].count(axis=1)/total_sims
|
193 |
players_only['Top_5_finish'] = players_only[players_only <= 5].count(axis=1)/total_sims
|
194 |
players_only['Top_10_finish'] = players_only[players_only <= 10].count(axis=1)/total_sims
|
195 |
players_only['20+%'] = overall_file[overall_file >= 20].count(axis=1)/float(total_sims)
|
196 |
+
players_only['3x%'] = salary_2x_check[salary_2x_check >= 1].count(axis=1)/float(total_sims)
|
197 |
+
players_only['4x%'] = salary_3x_check[salary_3x_check >= 1].count(axis=1)/float(total_sims)
|
198 |
+
players_only['5x%'] = salary_4x_check[salary_4x_check >= 1].count(axis=1)/float(total_sims)
|
199 |
+
players_only['GPP%'] = salary_4x_check[gpp_check >= 1].count(axis=1)/float(total_sims)
|
200 |
+
|
201 |
players_only['Player'] = hold_file[['Player']]
|
202 |
+
|
203 |
+
final_outcomes = players_only[['Player', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '3x%', '4x%', '5x%', 'GPP%']]
|
204 |
|
205 |
final_Proj = pd.merge(hold_file, final_outcomes, on="Player")
|
206 |
+
final_Proj = final_Proj[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '3x%', '4x%', '5x%', 'GPP%']]
|
207 |
+
|
208 |
final_Proj['Own'] = final_Proj['Player'].map(own_dict)
|
209 |
+
final_Proj['Minutes Proj'] = final_Proj['Player'].map(min_dict)
|
210 |
final_Proj['Team'] = final_Proj['Player'].map(team_dict)
|
211 |
+
final_Proj['Own'] = final_Proj['Own'].astype('float')
|
212 |
+
final_Proj['LevX'] = ((final_Proj[['Top_finish', '4x%', 'Top_5_finish']].mean(axis=1))*100) - final_Proj['Own']
|
213 |
+
final_Proj['ValX'] = ((final_Proj[['4x%', '5x%']].mean(axis=1))*100) + final_Proj['LevX']
|
214 |
+
|
215 |
+
final_Proj = final_Proj[['Player', 'Minutes Proj', 'Position', 'Team', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '3x%', '4x%', '5x%', 'GPP%', 'Own', 'LevX', 'ValX']]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
final_Proj = final_Proj.set_index('Player')
|
217 |
+
final_Proj = final_Proj.sort_values(by='Median', ascending=False)
|
218 |
+
|
219 |
+
st.session_state.final_Proj = final_Proj
|
220 |
+
|
221 |
hold_container = st.empty()
|
|
|
|
|
222 |
|
223 |
+
with display_container:
|
224 |
+
display_container = st.empty()
|
225 |
+
if 'final_Proj' in st.session_state:
|
226 |
+
if pos_var1 == 'All':
|
227 |
+
st.session_state.final_Proj = st.session_state.final_Proj
|
228 |
+
elif pos_var1 != 'All':
|
229 |
+
st.session_state.final_Proj = st.session_state.final_Proj[st.session_state.final_Proj['Position'].str.contains(pos_var1)]
|
230 |
+
st.dataframe(st.session_state.final_Proj.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
231 |
+
|
232 |
+
with display_dl_container:
|
233 |
+
display_dl_container = st.empty()
|
234 |
+
if 'final_Proj' in st.session_state:
|
235 |
+
st.download_button(
|
236 |
+
label="Export Tables",
|
237 |
+
data=convert_df_to_csv(st.session_state.final_Proj),
|
238 |
+
file_name='Custom_NBA_export.csv',
|
239 |
+
mime='text/csv',
|
240 |
+
)
|