James McCool commited on
Commit
9b90f9a
·
1 Parent(s): 4166ef5

Add CPT/FLEX selection options in 'Manage Portfolio' section of 'app.py' to enhance player filtering capabilities based on slot type.

Browse files
Files changed (1) hide show
  1. app.py +47 -3
app.py CHANGED
@@ -1660,8 +1660,10 @@ if selected_tab == 'Manage Portfolio':
1660
  player_names.update(st.session_state['working_frame'][col].unique())
1661
  keep_remove_var = st.selectbox("Conditional:", options=['Keep', 'Remove'], index=0)
1662
  conditional_side_alpha = st.multiselect("Lineups containing:", options=sorted(list(player_names)), default=[])
 
1663
  conditional_var = st.selectbox("where they also contain:", options=['Any', 'All', 'None'], index=0)
1664
  conditional_side_beta = st.multiselect("of the following player(s):", options=sorted(list(player_names)), default=[])
 
1665
 
1666
  submitted_col, export_col = st.columns(2)
1667
  st.info("Portfolio Button applies to your overall Portfolio, Export button applies to your Custom Export")
@@ -1678,7 +1680,15 @@ if selected_tab == 'Manage Portfolio':
1678
  # Create boolean mask for rows containing ALL players from alpha side
1679
  alpha_mask = pd.Series([True] * len(parsed_frame), index=parsed_frame.index)
1680
  for player in conditional_side_alpha:
1681
- player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
 
 
 
 
 
 
 
 
1682
  alpha_mask = alpha_mask & player_present
1683
 
1684
  # Only apply beta logic to rows that match alpha condition
@@ -1689,18 +1699,43 @@ if selected_tab == 'Manage Portfolio':
1689
  # Check if row contains ANY of the beta players
1690
  beta_mask = pd.Series([False] * len(parsed_frame), index=parsed_frame.index)
1691
  for player in conditional_side_beta:
1692
- player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
 
 
 
 
 
 
 
 
1693
  beta_mask = beta_mask | player_present
1694
  elif conditional_var == 'All':
1695
  # Check if row contains ALL of the beta players
1696
  beta_mask = pd.Series([True] * len(parsed_frame), index=parsed_frame.index)
1697
  for player in conditional_side_beta:
1698
- player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
 
 
 
 
 
 
 
 
1699
  beta_mask = beta_mask & player_present
1700
  elif conditional_var == 'None':
1701
  # Check if row contains NONE of the beta players
1702
  beta_mask = pd.Series([True] * len(parsed_frame), index=parsed_frame.index)
1703
  for player in conditional_side_beta:
 
 
 
 
 
 
 
 
 
1704
  player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
1705
  beta_mask = beta_mask & (~player_present)
1706
 
@@ -1717,6 +1752,15 @@ if selected_tab == 'Manage Portfolio':
1717
  # Only alpha side specified - filter based on presence of alpha players
1718
  alpha_mask = pd.Series([True] * len(parsed_frame), index=parsed_frame.index)
1719
  for player in conditional_side_alpha:
 
 
 
 
 
 
 
 
 
1720
  player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
1721
  alpha_mask = alpha_mask & player_present
1722
 
 
1660
  player_names.update(st.session_state['working_frame'][col].unique())
1661
  keep_remove_var = st.selectbox("Conditional:", options=['Keep', 'Remove'], index=0)
1662
  conditional_side_alpha = st.multiselect("Lineups containing:", options=sorted(list(player_names)), default=[])
1663
+ cpt_flex_alpha = st.selectbox("in slot:", options=['Overall', 'CPT', 'FLEX'], index=0)
1664
  conditional_var = st.selectbox("where they also contain:", options=['Any', 'All', 'None'], index=0)
1665
  conditional_side_beta = st.multiselect("of the following player(s):", options=sorted(list(player_names)), default=[])
1666
+ cpt_flex_beta = st.selectbox("in slot:", options=['Overall', 'CPT', 'FLEX'], index=0)
1667
 
1668
  submitted_col, export_col = st.columns(2)
1669
  st.info("Portfolio Button applies to your overall Portfolio, Export button applies to your Custom Export")
 
1680
  # Create boolean mask for rows containing ALL players from alpha side
1681
  alpha_mask = pd.Series([True] * len(parsed_frame), index=parsed_frame.index)
1682
  for player in conditional_side_alpha:
1683
+ if type_var == 'Showdown':
1684
+ if cpt_flex_alpha == 'Overall':
1685
+ player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
1686
+ elif cpt_flex_alpha == 'CPT':
1687
+ player_present = parsed_frame.iloc[:, 0].apply(lambda row: player in row.values)
1688
+ elif cpt_flex_alpha == 'FLEX':
1689
+ player_present = parsed_frame.iloc[:, 1:].apply(lambda row: player in row.values, axis=1)
1690
+ else:
1691
+ player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
1692
  alpha_mask = alpha_mask & player_present
1693
 
1694
  # Only apply beta logic to rows that match alpha condition
 
1699
  # Check if row contains ANY of the beta players
1700
  beta_mask = pd.Series([False] * len(parsed_frame), index=parsed_frame.index)
1701
  for player in conditional_side_beta:
1702
+ if type_var == 'Showdown':
1703
+ if cpt_flex_beta == 'Overall':
1704
+ player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
1705
+ elif cpt_flex_beta == 'CPT':
1706
+ player_present = parsed_frame.iloc[:, 0].apply(lambda row: player in row.values)
1707
+ elif cpt_flex_beta == 'FLEX':
1708
+ player_present = parsed_frame.iloc[:, 1:].apply(lambda row: player in row.values, axis=1)
1709
+ else:
1710
+ player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
1711
  beta_mask = beta_mask | player_present
1712
  elif conditional_var == 'All':
1713
  # Check if row contains ALL of the beta players
1714
  beta_mask = pd.Series([True] * len(parsed_frame), index=parsed_frame.index)
1715
  for player in conditional_side_beta:
1716
+ if type_var == 'Showdown':
1717
+ if cpt_flex_beta == 'Overall':
1718
+ player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
1719
+ elif cpt_flex_beta == 'CPT':
1720
+ player_present = parsed_frame.iloc[:, 0].apply(lambda row: player in row.values)
1721
+ elif cpt_flex_beta == 'FLEX':
1722
+ player_present = parsed_frame.iloc[:, 1:].apply(lambda row: player in row.values, axis=1)
1723
+ else:
1724
+ player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
1725
  beta_mask = beta_mask & player_present
1726
  elif conditional_var == 'None':
1727
  # Check if row contains NONE of the beta players
1728
  beta_mask = pd.Series([True] * len(parsed_frame), index=parsed_frame.index)
1729
  for player in conditional_side_beta:
1730
+ if type_var == 'Showdown':
1731
+ if cpt_flex_beta == 'Overall':
1732
+ player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
1733
+ elif cpt_flex_beta == 'CPT':
1734
+ player_present = parsed_frame.iloc[:, 0].apply(lambda row: player in row.values)
1735
+ elif cpt_flex_beta == 'FLEX':
1736
+ player_present = parsed_frame.iloc[:, 1:].apply(lambda row: player in row.values, axis=1)
1737
+ else:
1738
+ player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
1739
  player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
1740
  beta_mask = beta_mask & (~player_present)
1741
 
 
1752
  # Only alpha side specified - filter based on presence of alpha players
1753
  alpha_mask = pd.Series([True] * len(parsed_frame), index=parsed_frame.index)
1754
  for player in conditional_side_alpha:
1755
+ if type_var == 'Showdown':
1756
+ if cpt_flex_alpha == 'Overall':
1757
+ player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
1758
+ elif cpt_flex_alpha == 'CPT':
1759
+ player_present = parsed_frame.iloc[:, 0].apply(lambda row: player in row.values)
1760
+ elif cpt_flex_alpha == 'FLEX':
1761
+ player_present = parsed_frame.iloc[:, 1:].apply(lambda row: player in row.values, axis=1)
1762
+ else:
1763
+ player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
1764
  player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
1765
  alpha_mask = alpha_mask & player_present
1766