James McCool commited on
Commit
d4642ad
·
1 Parent(s): 379842b

added seed frame frequencies

Browse files
Files changed (1) hide show
  1. app.py +65 -30
app.py CHANGED
@@ -513,35 +513,70 @@ with tab2:
513
  }).background_gradient(cmap='RdYlGn', axis=0, subset=['Salary', 'Proj', 'Own']), use_container_width=True)
514
 
515
  with st.container():
516
- if 'data_export_display' in st.session_state:
517
- if site_var1 == 'Draftkings':
518
- player_columns = st.session_state.data_export_display.iloc[:, :8]
519
- elif site_var1 == 'Fanduel':
520
- player_columns = st.session_state.data_export_display.iloc[:, :9]
521
-
522
- # Flatten the DataFrame and count unique values
523
- value_counts = player_columns.values.flatten().tolist()
524
- value_counts = pd.Series(value_counts).value_counts()
525
-
526
- percentages = (value_counts / lineup_num_var * 100).round(2)
527
-
528
- # Create a DataFrame with the results
529
- summary_df = pd.DataFrame({
530
- 'Player': value_counts.index,
531
- 'Frequency': value_counts.values,
532
- 'Percentage': percentages.values
533
- })
 
 
 
 
 
 
 
 
 
534
 
535
- # Sort by frequency in descending order
536
- summary_df = summary_df.sort_values('Frequency', ascending=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
537
 
538
- # Display the table
539
- st.write("Player Frequency Table:")
540
- st.dataframe(summary_df.style.format({'Percentage': '{:.2f}%'}), height=500, use_container_width=True)
541
-
542
- st.download_button(
543
- label="Export player frequency",
544
- data=convert_df_to_csv(summary_df),
545
- file_name='NBA_player_frequency.csv',
546
- mime='text/csv',
547
- )
 
513
  }).background_gradient(cmap='RdYlGn', axis=0, subset=['Salary', 'Proj', 'Own']), use_container_width=True)
514
 
515
  with st.container():
516
+ tab1, tab2 = st.tabs(["Display Frequency", "Seed Frame Frequency"])
517
+ with tab1:
518
+ if 'data_export_display' in st.session_state:
519
+ if site_var1 == 'Draftkings':
520
+ player_columns = st.session_state.data_export_display.iloc[:, :8]
521
+ elif site_var1 == 'Fanduel':
522
+ player_columns = st.session_state.data_export_display.iloc[:, :9]
523
+
524
+ # Flatten the DataFrame and count unique values
525
+ value_counts = player_columns.values.flatten().tolist()
526
+ value_counts = pd.Series(value_counts).value_counts()
527
+
528
+ percentages = (value_counts / lineup_num_var * 100).round(2)
529
+
530
+ # Create a DataFrame with the results
531
+ summary_df = pd.DataFrame({
532
+ 'Player': value_counts.index,
533
+ 'Frequency': value_counts.values,
534
+ 'Percentage': percentages.values
535
+ })
536
+
537
+ # Sort by frequency in descending order
538
+ summary_df = summary_df.sort_values('Frequency', ascending=False)
539
+
540
+ # Display the table
541
+ st.write("Player Frequency Table:")
542
+ st.dataframe(summary_df.style.format({'Percentage': '{:.2f}%'}), height=500, use_container_width=True)
543
 
544
+ st.download_button(
545
+ label="Export player frequency",
546
+ data=convert_df_to_csv(summary_df),
547
+ file_name='NBA_player_frequency.csv',
548
+ mime='text/csv',
549
+ )
550
+ with tab2:
551
+ if 'working_seed' in st.session_state:
552
+ if site_var1 == 'Draftkings':
553
+ player_columns = st.session_state.working_seed.iloc[:, :8]
554
+ elif site_var1 == 'Fanduel':
555
+ player_columns = st.session_state.working_seed.iloc[:, :9]
556
+
557
+ # Flatten the DataFrame and count unique values
558
+ value_counts = player_columns.values.flatten().tolist()
559
+ value_counts = pd.Series(value_counts).value_counts()
560
+
561
+ percentages = (value_counts / len(st.session_state.working_seed) * 100).round(2)
562
+
563
+ # Create a DataFrame with the results
564
+ summary_df = pd.DataFrame({
565
+ 'Player': value_counts.index,
566
+ 'Frequency': value_counts.values,
567
+ 'Percentage': percentages.values
568
+ })
569
+
570
+ # Sort by frequency in descending order
571
+ summary_df = summary_df.sort_values('Frequency', ascending=False)
572
+
573
+ # Display the table
574
+ st.write("Seed Frame Frequency Table:")
575
+ st.dataframe(summary_df.style.format({'Percentage': '{:.2f}%'}), height=500, use_container_width=True)
576
 
577
+ st.download_button(
578
+ label="Export seed frame frequency",
579
+ data=convert_df_to_csv(summary_df),
580
+ file_name='NBA_seed_frame_frequency.csv',
581
+ mime='text/csv',
582
+ )