James McCool commited on
Commit
ee7eab7
·
1 Parent(s): 2bc1ea4

Working with dicts instead of backfilling

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -226,19 +226,19 @@ with tab4:
226
  market_type = st.selectbox('Select type of prop are you wanting to view', options = prop_table_options, key = 'market_type_key')
227
  disp_market = market_props.copy()
228
  disp_market = disp_market[disp_market['PropType'] == market_type]
229
- disp_market['FANDUEL_Proj'] = disp_market.apply(lambda x: x['Projection'] if x['OddsType'] == 'FANDUEL' else None, axis=1)
230
- disp_market['DRAFTKINGS_Proj'] = disp_market.apply(lambda x: x['Projection'] if x['OddsType'] == 'DRAFTKINGS' else None, axis=1)
231
- disp_market['MGM_Proj'] = disp_market.apply(lambda x: x['Projection'] if x['OddsType'] == 'MGM' else None, axis=1)
232
- disp_market['CONSENSUS_Proj'] = disp_market.apply(lambda x: x['Projection'] if x['OddsType'] == 'CONSENSUS' else None, axis=1)
233
-
234
- # Fill forward within groups to populate projection columns
235
- #disp_market = disp_market.groupby(['Name', 'PropType']).fillna(method='ffill').fillna(method='bfill')
236
-
237
- # Keep only one row per Name/prop combination
238
- #disp_market = disp_market.drop_duplicates(subset=['Name', 'PropType'], keep='first', ignore_index=True)
239
-
240
- # Select and order columns
241
- #disp_market = disp_market[['Name', 'Team', 'PropType', 'FANDUEL_Proj', 'DRAFTKINGS_Proj', 'MGM_Proj', 'CONSENSUS_Proj']]
242
 
243
  st.dataframe(disp_market.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(prop_format, precision=2), height = 1000, use_container_width = True)
244
  st.download_button(
 
226
  market_type = st.selectbox('Select type of prop are you wanting to view', options = prop_table_options, key = 'market_type_key')
227
  disp_market = market_props.copy()
228
  disp_market = disp_market[disp_market['PropType'] == market_type]
229
+ fanduel_frame = disp_market[disp_market['OddsType'] == 'FANDUEL']
230
+ fanduel_dict = dict(zip(fanduel_frame['Name'], fanduel_frame['Projection']))
231
+ draftkings_frame = disp_market[disp_market['OddsType'] == 'DRAFTKINGS']
232
+ draftkings_dict = dict(zip(draftkings_frame['Name'], draftkings_frame['Projection']))
233
+ mgm_frame = disp_market[disp_market['OddsType'] == 'MGM']
234
+ mgm_dict = dict(zip(mgm_frame['Name'], mgm_frame['Projection']))
235
+ consensus_frame = disp_market[disp_market['OddsType'] == 'CONSENSUS']
236
+ consensus_dict = dict(zip(consensus_frame['Name'], consensus_frame['Projection']))
237
+
238
+ disp_market['FANDUEL_Proj'] = disp_market['Name'].map(fanduel_dict)
239
+ disp_market['DRAFTKINGS_Proj'] = disp_market['Name'].map(draftkings_dict)
240
+ disp_market['MGM_Proj'] = disp_market['Name'].map(mgm_dict)
241
+ disp_market['CONSENSUS_Proj'] = disp_market['Name'].map(consensus_dict)
242
 
243
  st.dataframe(disp_market.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(prop_format, precision=2), height = 1000, use_container_width = True)
244
  st.download_button(