Spaces:
Running
Running
James McCool
commited on
Commit
·
a5d3c74
1
Parent(s):
82356a0
Add summary row to player selection display in Handbuilder tab of app.py, calculating total salary, median, and ownership percentage, and displaying the most common team for improved data insight and user experience.
Browse files
app.py
CHANGED
@@ -862,5 +862,34 @@ with tab4:
|
|
862 |
height=300,
|
863 |
hide_index=True
|
864 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
865 |
|
866 |
|
|
|
862 |
height=300,
|
863 |
hide_index=True
|
864 |
)
|
865 |
+
|
866 |
+
# --- SUMMARY ROW ---
|
867 |
+
if not select_players_disp.empty:
|
868 |
+
# Calculate sums
|
869 |
+
total_salary = select_players_disp['Salary'].sum()
|
870 |
+
total_median = select_players_disp['Median'].sum()
|
871 |
+
total_own = select_players_disp['Own%'].sum()
|
872 |
+
# Most common team
|
873 |
+
most_common_team = select_players_disp['Team'].mode()[0] if not select_players_disp['Team'].mode().empty else ""
|
874 |
+
|
875 |
+
# Create a summary row as a DataFrame
|
876 |
+
summary_row = pd.DataFrame({
|
877 |
+
'Player': ['TOTAL'],
|
878 |
+
'Team': [most_common_team],
|
879 |
+
'Salary': [total_salary],
|
880 |
+
'Median': [total_median],
|
881 |
+
'Own%': [total_own]
|
882 |
+
})
|
883 |
+
|
884 |
+
# Align columns with select_players_disp
|
885 |
+
summary_row = summary_row[select_players_disp.columns]
|
886 |
+
|
887 |
+
# Display the summary row
|
888 |
+
st.dataframe(
|
889 |
+
summary_row,
|
890 |
+
use_container_width=True,
|
891 |
+
height=50,
|
892 |
+
hide_index=True
|
893 |
+
)
|
894 |
|
895 |
|