Spaces:
Running
Running
James McCool
commited on
Commit
·
8852749
1
Parent(s):
2b2c50a
Refactor lineup display logic in app.py to ensure that the player data is only processed when the filled lineup is not empty. This change enhances the efficiency of the display logic and maintains clarity in the representation of player statistics.
Browse files
app.py
CHANGED
@@ -903,35 +903,35 @@ with tab4:
|
|
903 |
filled_lineup = st.session_state['handbuilder_lineup']
|
904 |
display_rows = []
|
905 |
used_indices = set()
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
|
936 |
lineup_display_df = pd.DataFrame(display_rows, columns=display_columns)
|
937 |
|
|
|
903 |
filled_lineup = st.session_state['handbuilder_lineup']
|
904 |
display_rows = []
|
905 |
used_indices = set()
|
906 |
+
if not filled_lineup.empty:
|
907 |
+
for slot in lineup_slots:
|
908 |
+
match = filled_lineup[(filled_lineup['Slot'] == slot) & (~filled_lineup.index.isin(used_indices))]
|
909 |
+
if not match.empty:
|
910 |
+
row = match.iloc[0]
|
911 |
+
used_indices.add(match.index[0])
|
912 |
+
display_rows.append({
|
913 |
+
'Slot': slot,
|
914 |
+
'Player': row['Player'],
|
915 |
+
'Order': row['Order'],
|
916 |
+
'Position': row['Position'],
|
917 |
+
'Team': row['Team'],
|
918 |
+
'Salary': row['Salary'],
|
919 |
+
'Median': row['Median'],
|
920 |
+
'2x%': row['2x%'],
|
921 |
+
'Own%': row['Own%']
|
922 |
+
})
|
923 |
+
else:
|
924 |
+
display_rows.append({
|
925 |
+
'Slot': slot,
|
926 |
+
'Player': '',
|
927 |
+
'Order': np.nan,
|
928 |
+
'Position': '',
|
929 |
+
'Team': '',
|
930 |
+
'Salary': np.nan,
|
931 |
+
'Median': np.nan,
|
932 |
+
'2x%': np.nan,
|
933 |
+
'Own%': np.nan
|
934 |
+
})
|
935 |
|
936 |
lineup_display_df = pd.DataFrame(display_rows, columns=display_columns)
|
937 |
|