Spaces:
Running
Running
James McCool
commited on
Commit
·
9caa087
1
Parent(s):
511fd8d
Refactor app.py to improve data display and conditional rendering in simulation tabs. Added checks for session state data before rendering player summaries, overall simulations, individual game data, and opponent boosts. This change enhances user experience by ensuring that only available data is displayed, improving clarity and interaction during simulations.
Browse files
app.py
CHANGED
@@ -690,14 +690,16 @@ if st.button("Run"):
|
|
690 |
st.session_state.overall_sim_df = pd.DataFrame(overall_sim_results)
|
691 |
st.session_state.overall_sim_df = st.session_state.overall_sim_df.drop_duplicates(subset = ['Player', 'Stat'])
|
692 |
|
693 |
-
|
694 |
-
|
|
|
695 |
st.subheader("Full Match Data")
|
696 |
st.dataframe(st.session_state.player_summary.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(display_formats, precision=2), use_container_width = True)
|
697 |
|
|
|
698 |
st.subheader("Overall Simulations")
|
699 |
stat_tabs = st.tabs(["Kills", "Deaths", "Assists", "CS"])
|
700 |
-
|
701 |
for stat, tab in zip(["Kills", "Deaths", "Assists", "CS"], stat_tabs):
|
702 |
with tab:
|
703 |
st.session_state.stat_data = st.session_state.overall_sim_df[st.session_state.overall_sim_df['Stat'] == stat].copy()
|
@@ -706,7 +708,7 @@ if st.button("Run"):
|
|
706 |
st.session_state.stat_data.style.format(precision=2).background_gradient(axis=0).background_gradient(cmap='RdYlGn'),
|
707 |
use_container_width=True
|
708 |
)
|
709 |
-
|
710 |
st.subheader("Prop Check")
|
711 |
col1, col2 = st.columns([2, 8])
|
712 |
with col1:
|
@@ -744,10 +746,12 @@ if st.button("Run"):
|
|
744 |
use_container_width=True
|
745 |
)
|
746 |
|
747 |
-
|
|
|
748 |
st.subheader("Individual Game Data")
|
749 |
st.dataframe(st.session_state.team_data.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(display_formats, precision=2), use_container_width = True)
|
750 |
|
|
|
751 |
st.subheader("Individual Game Simulations")
|
752 |
unique_players = st.session_state.sim_df['Player'].unique().tolist()
|
753 |
player_tabs = st.tabs(unique_players)
|
@@ -762,5 +766,7 @@ if st.button("Run"):
|
|
762 |
use_container_width=True
|
763 |
)
|
764 |
|
765 |
-
|
|
|
|
|
766 |
st.dataframe(st.session_state.opp_boost.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
|
|
690 |
st.session_state.overall_sim_df = pd.DataFrame(overall_sim_results)
|
691 |
st.session_state.overall_sim_df = st.session_state.overall_sim_df.drop_duplicates(subset = ['Player', 'Stat'])
|
692 |
|
693 |
+
tab1, tab2, tab3 = st.tabs(["Overall Data", "Individual Game Data", "Opponent Data"])
|
694 |
+
with tab1:
|
695 |
+
if st.session_state.player_summary is not None:
|
696 |
st.subheader("Full Match Data")
|
697 |
st.dataframe(st.session_state.player_summary.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(display_formats, precision=2), use_container_width = True)
|
698 |
|
699 |
+
if st.session_state.overall_sim_df is not None:
|
700 |
st.subheader("Overall Simulations")
|
701 |
stat_tabs = st.tabs(["Kills", "Deaths", "Assists", "CS"])
|
702 |
+
|
703 |
for stat, tab in zip(["Kills", "Deaths", "Assists", "CS"], stat_tabs):
|
704 |
with tab:
|
705 |
st.session_state.stat_data = st.session_state.overall_sim_df[st.session_state.overall_sim_df['Stat'] == stat].copy()
|
|
|
708 |
st.session_state.stat_data.style.format(precision=2).background_gradient(axis=0).background_gradient(cmap='RdYlGn'),
|
709 |
use_container_width=True
|
710 |
)
|
711 |
+
|
712 |
st.subheader("Prop Check")
|
713 |
col1, col2 = st.columns([2, 8])
|
714 |
with col1:
|
|
|
746 |
use_container_width=True
|
747 |
)
|
748 |
|
749 |
+
with tab2:
|
750 |
+
if st.session_state.team_data is not None:
|
751 |
st.subheader("Individual Game Data")
|
752 |
st.dataframe(st.session_state.team_data.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(display_formats, precision=2), use_container_width = True)
|
753 |
|
754 |
+
if st.session_state.sim_df is not None:
|
755 |
st.subheader("Individual Game Simulations")
|
756 |
unique_players = st.session_state.sim_df['Player'].unique().tolist()
|
757 |
player_tabs = st.tabs(unique_players)
|
|
|
766 |
use_container_width=True
|
767 |
)
|
768 |
|
769 |
+
with tab3:
|
770 |
+
if st.session_state.opp_boost is not None:
|
771 |
+
st.subheader("Opponent Boosts")
|
772 |
st.dataframe(st.session_state.opp_boost.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|