James McCool commited on
Commit
b985a1c
·
1 Parent(s): 6a4d277

Refactor data loading and processing in the main function of the Streamlit app. Removed try-except block for data loading, streamlining the flow by directly loading projections and ranks data before creating position frames and calculating VORP metrics. Enhanced the display of player rankings and position breakdowns.

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +26 -32
src/streamlit_app.py CHANGED
@@ -412,39 +412,33 @@ def main():
412
 
413
  # Get user configuration
414
  user_league_settings, user_flex_percentiles, user_flex_multipliers, user_pos_vorp_limiters = create_user_config_interface()
 
 
 
415
 
416
- # Load data
417
- try:
418
- projections_df = load_projections_data(Dwain_proj)
419
- ranks_dict = load_ranks_data(dwain_ranks)
420
-
421
- # Create position frames
422
- position_df = create_position_frames(projections_df, ranks_dict)
423
-
424
- # Calculate position requirements
425
- pos_reqs = designate_custom_position_reqs(user_league_settings, user_flex_percentiles, user_flex_multipliers)
426
-
427
- # Calculate replacement values
428
- halfPpr_rv = create_halfPpr_rv(position_df, pos_reqs)
429
- custom_rv = create_custom_rv(position_df, pos_reqs, user_league_settings)
430
-
431
- # Calculate VORP and rankings
432
- final_df = assign_vorp(position_df, halfPpr_rv, custom_rv, user_league_settings, user_pos_vorp_limiters)
433
-
434
- # Display results
435
- st.header("Player Rankings")
436
- st.dataframe(final_df[['Name', 'Pos', 'Rank', 'custom_rank', 'halfPpr', 'custom_VORP', 'halfPpr_VORP']].head(50))
437
-
438
- # Position breakdown
439
- st.header("Position Breakdown")
440
- for pos in ['QB', 'RB', 'WR', 'TE']:
441
- pos_df = final_df[final_df['Pos'] == pos].head(20)
442
- st.subheader(f"Top {pos}s")
443
- st.dataframe(pos_df[['Name', 'Rank', 'custom_rank', 'halfPpr', 'custom_VORP']])
444
-
445
- except Exception as e:
446
- st.error(f"Error loading data: {str(e)}")
447
- st.info("Please check your internet connection and try again.")
448
 
449
  if __name__ == "__main__":
450
  main()
 
412
 
413
  # Get user configuration
414
  user_league_settings, user_flex_percentiles, user_flex_multipliers, user_pos_vorp_limiters = create_user_config_interface()
415
+
416
+ projections_df = load_projections_data(Dwain_proj)
417
+ ranks_dict = load_ranks_data(dwain_ranks)
418
 
419
+ # Create position frames
420
+ position_df = create_position_frames(projections_df, ranks_dict)
421
+
422
+ # Calculate position requirements
423
+ pos_reqs = designate_custom_position_reqs(user_league_settings, user_flex_percentiles, user_flex_multipliers)
424
+
425
+ # Calculate replacement values
426
+ halfPpr_rv = create_halfPpr_rv(position_df, pos_reqs)
427
+ custom_rv = create_custom_rv(position_df, pos_reqs, user_league_settings)
428
+
429
+ # Calculate VORP and rankings
430
+ final_df = assign_vorp(position_df, halfPpr_rv, custom_rv, user_league_settings, user_pos_vorp_limiters)
431
+
432
+ # Display results
433
+ st.header("Player Rankings")
434
+ st.dataframe(final_df[['Name', 'Pos', 'Rank', 'custom_rank', 'halfPpr', 'custom_VORP', 'halfPpr_VORP']].head(50))
435
+
436
+ # Position breakdown
437
+ st.header("Position Breakdown")
438
+ for pos in ['QB', 'RB', 'WR', 'TE']:
439
+ pos_df = final_df[final_df['Pos'] == pos].head(20)
440
+ st.subheader(f"Top {pos}s")
441
+ st.dataframe(pos_df[['Name', 'Rank', 'custom_rank', 'halfPpr', 'custom_VORP']])
 
 
 
 
 
 
 
 
 
442
 
443
  if __name__ == "__main__":
444
  main()