Spaces:
Running
Running
James McCool
commited on
Commit
·
aa1ddcc
1
Parent(s):
fa0e4a7
Update Handbuilder lineup DataFrame in app.py to include 'Order' column for improved player management and display. Adjust related logic to ensure consistent handling of player data across the application, enhancing clarity and user experience.
Browse files
app.py
CHANGED
@@ -817,7 +817,7 @@ with tab4:
|
|
817 |
|
818 |
# --- LINEUP STATE ---
|
819 |
if 'handbuilder_lineup' not in st.session_state:
|
820 |
-
st.session_state['handbuilder_lineup'] = pd.DataFrame(columns=['Player', 'Position', 'Team', 'Salary', 'Median', 'Own%'])
|
821 |
if 'handbuilder_select_key' not in st.session_state:
|
822 |
st.session_state['handbuilder_select_key'] = 0
|
823 |
|
@@ -887,7 +887,7 @@ with tab4:
|
|
887 |
# Add the slot info
|
888 |
player_row = player_row.assign(Slot=slot_to_fill)
|
889 |
st.session_state['handbuilder_lineup'] = pd.concat(
|
890 |
-
[st.session_state['handbuilder_lineup'], player_row[['Player', 'Position', 'Team', 'Salary', 'Median', 'Own%', 'Slot']]],
|
891 |
ignore_index=True
|
892 |
)
|
893 |
st.session_state['handbuilder_select_key'] += 1
|
@@ -898,7 +898,7 @@ with tab4:
|
|
898 |
|
899 |
# --- EXPLICIT LINEUP ORDER ---
|
900 |
lineup_slots = ['SP', 'SP', 'C', '1B', '2B', '3B', 'SS', 'OF', 'OF', 'OF']
|
901 |
-
display_columns = ['Slot', 'Player', 'Position', 'Team', 'Salary', 'Median', 'Own%']
|
902 |
|
903 |
# Prepare a DataFrame for display in the explicit order
|
904 |
filled_lineup = st.session_state['handbuilder_lineup']
|
@@ -914,6 +914,7 @@ with tab4:
|
|
914 |
display_rows.append({
|
915 |
'Slot': slot,
|
916 |
'Player': row['Player'],
|
|
|
917 |
'Position': row['Position'],
|
918 |
'Team': row['Team'],
|
919 |
'Salary': row['Salary'],
|
@@ -925,6 +926,7 @@ with tab4:
|
|
925 |
display_rows.append({
|
926 |
'Slot': slot,
|
927 |
'Player': '',
|
|
|
928 |
'Position': '',
|
929 |
'Team': '',
|
930 |
'Salary': '',
|
@@ -951,6 +953,7 @@ with tab4:
|
|
951 |
summary_row = pd.DataFrame({
|
952 |
'Slot': [''],
|
953 |
'Player': ['TOTAL'],
|
|
|
954 |
'Position': [''],
|
955 |
'Team': [most_common_team],
|
956 |
'Salary': [total_salary],
|
@@ -968,5 +971,5 @@ with tab4:
|
|
968 |
|
969 |
# Optionally, add a button to clear the lineup
|
970 |
if st.button("Clear Lineup", key='clear_lineup'):
|
971 |
-
st.session_state['handbuilder_lineup'] = pd.DataFrame(columns=['Player', 'Position', 'Team', 'Salary', 'Median', 'Own%', 'Slot'])
|
972 |
st.rerun()
|
|
|
817 |
|
818 |
# --- LINEUP STATE ---
|
819 |
if 'handbuilder_lineup' not in st.session_state:
|
820 |
+
st.session_state['handbuilder_lineup'] = pd.DataFrame(columns=['Player', 'Order', 'Position', 'Team', 'Salary', 'Median', 'Own%'])
|
821 |
if 'handbuilder_select_key' not in st.session_state:
|
822 |
st.session_state['handbuilder_select_key'] = 0
|
823 |
|
|
|
887 |
# Add the slot info
|
888 |
player_row = player_row.assign(Slot=slot_to_fill)
|
889 |
st.session_state['handbuilder_lineup'] = pd.concat(
|
890 |
+
[st.session_state['handbuilder_lineup'], player_row[['Player', 'Order', 'Position', 'Team', 'Salary', 'Median', 'Own%', 'Slot']]],
|
891 |
ignore_index=True
|
892 |
)
|
893 |
st.session_state['handbuilder_select_key'] += 1
|
|
|
898 |
|
899 |
# --- EXPLICIT LINEUP ORDER ---
|
900 |
lineup_slots = ['SP', 'SP', 'C', '1B', '2B', '3B', 'SS', 'OF', 'OF', 'OF']
|
901 |
+
display_columns = ['Slot', 'Player', 'Order', 'Position', 'Team', 'Salary', 'Median', 'Own%']
|
902 |
|
903 |
# Prepare a DataFrame for display in the explicit order
|
904 |
filled_lineup = st.session_state['handbuilder_lineup']
|
|
|
914 |
display_rows.append({
|
915 |
'Slot': slot,
|
916 |
'Player': row['Player'],
|
917 |
+
'Order': row['Order'],
|
918 |
'Position': row['Position'],
|
919 |
'Team': row['Team'],
|
920 |
'Salary': row['Salary'],
|
|
|
926 |
display_rows.append({
|
927 |
'Slot': slot,
|
928 |
'Player': '',
|
929 |
+
'Order': '',
|
930 |
'Position': '',
|
931 |
'Team': '',
|
932 |
'Salary': '',
|
|
|
953 |
summary_row = pd.DataFrame({
|
954 |
'Slot': [''],
|
955 |
'Player': ['TOTAL'],
|
956 |
+
'Order': [''],
|
957 |
'Position': [''],
|
958 |
'Team': [most_common_team],
|
959 |
'Salary': [total_salary],
|
|
|
971 |
|
972 |
# Optionally, add a button to clear the lineup
|
973 |
if st.button("Clear Lineup", key='clear_lineup'):
|
974 |
+
st.session_state['handbuilder_lineup'] = pd.DataFrame(columns=['Player', 'Position', 'Team', 'Salary', 'Median', 'Own%', 'Slot', 'Order'])
|
975 |
st.rerun()
|