James McCool commited on
Commit
6900faf
·
1 Parent(s): 12804c6

Update app.py to switch database connections for DK and FD lineups, modify displayed columns, and enhance player data filtering with a radio button for site selection, improving user experience and data management.

Browse files
Files changed (1) hide show
  1. app.py +14 -5
app.py CHANGED
@@ -77,17 +77,18 @@ def init_baselines():
77
  cursor = collection.find()
78
  team_frame = pd.DataFrame(cursor)
79
  scoring_percentages = team_frame.drop(columns=['_id'])
 
80
 
81
  return roo_data, sd_roo_data, scoring_percentages
82
 
83
  @st.cache_data(ttl = 60)
84
  def init_DK_lineups():
85
 
86
- collection = db['DK_MLB_SD1_seed_frame']
87
  cursor = collection.find().limit(10000)
88
 
89
  raw_display = pd.DataFrame(list(cursor))
90
- raw_display = raw_display[['FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'FLEX6', 'salary', 'proj', 'Own']]
91
  DK_seed = raw_display.to_numpy()
92
 
93
  return DK_seed
@@ -95,11 +96,11 @@ def init_DK_lineups():
95
  @st.cache_data(ttl = 60)
96
  def init_FD_lineups():
97
 
98
- collection = db['FD_MLB_SD1_seed_frame']
99
  cursor = collection.find().limit(10000)
100
 
101
  raw_display = pd.DataFrame(list(cursor))
102
- raw_display = raw_display[['FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'FLEX6', 'salary', 'proj', 'Own']]
103
  FD_seed = raw_display.to_numpy()
104
 
105
  return FD_seed
@@ -125,7 +126,15 @@ with tab1:
125
 
126
  with tab2:
127
  st.title("Player ROO")
128
- st.dataframe(sd_roo_data)
 
 
 
 
 
 
 
 
129
 
130
  with tab3:
131
  with st.expander("Info and Filters"):
 
77
  cursor = collection.find()
78
  team_frame = pd.DataFrame(cursor)
79
  scoring_percentages = team_frame.drop(columns=['_id'])
80
+ scoring_percentages = scoring_percentages[['Names', 'Avg First Inning', 'First Inning Lead Percentage', 'Avg Fifth Inning', 'Fifth Inning Lead Percentage', 'Avg Score', '8+ runs', 'Win Percentage']]
81
 
82
  return roo_data, sd_roo_data, scoring_percentages
83
 
84
  @st.cache_data(ttl = 60)
85
  def init_DK_lineups():
86
 
87
+ collection = db2['DK_MLB_SD1_seed_frame']
88
  cursor = collection.find().limit(10000)
89
 
90
  raw_display = pd.DataFrame(list(cursor))
91
+ raw_display = raw_display[['CPT', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'FLEX6', 'salary', 'proj', 'Own']]
92
  DK_seed = raw_display.to_numpy()
93
 
94
  return DK_seed
 
96
  @st.cache_data(ttl = 60)
97
  def init_FD_lineups():
98
 
99
+ collection = db2['FD_MLB_SD1_seed_frame']
100
  cursor = collection.find().limit(10000)
101
 
102
  raw_display = pd.DataFrame(list(cursor))
103
+ raw_display = raw_display[['CPT', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'salary', 'proj', 'Own']]
104
  FD_seed = raw_display.to_numpy()
105
 
106
  return FD_seed
 
126
 
127
  with tab2:
128
  st.title("Player ROO")
129
+ with st.expander("Info and Filters"):
130
+ site_var = st.radio("Select site", ["Draftkings", "Fanduel"])
131
+ if site_var == "Draftkings":
132
+ display_data = sd_roo_data[sd_roo_data['site'] == 'Draftkings']
133
+ display_data = display_data[display_data['slate'] == 'DK SD1']
134
+ elif site_var == "Fanduel":
135
+ display_data = sd_roo_data[sd_roo_data['site'] == 'Fanduel']
136
+ display_data = display_data[display_data['slate'] == 'FD SD1']
137
+ st.dataframe(display_data)
138
 
139
  with tab3:
140
  with st.expander("Info and Filters"):