Spaces:
Running
Running
Jon Solow
commited on
Commit
·
a3b2378
1
Parent(s):
7c958be
Add toggle for subtotals and percents
Browse files- src/pages/5_Targets.py +14 -0
src/pages/5_Targets.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import datetime
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
|
| 4 |
from config import DEFAULT_ICON
|
|
@@ -27,6 +28,19 @@ def get_page():
|
|
| 27 |
data, data_load_time_str = load_data()
|
| 28 |
st.write(f"Data loaded as of: {data_load_time_str} UTC")
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
with st.container():
|
| 31 |
filtered_data = filter_dataframe(data)
|
| 32 |
st.dataframe(
|
|
|
|
| 1 |
import datetime
|
| 2 |
+
import numpy as np
|
| 3 |
import streamlit as st
|
| 4 |
|
| 5 |
from config import DEFAULT_ICON
|
|
|
|
| 28 |
data, data_load_time_str = load_data()
|
| 29 |
st.write(f"Data loaded as of: {data_load_time_str} UTC")
|
| 30 |
|
| 31 |
+
selected_subtotals = st.selectbox("Show:", ["Player Totals", "Position Totals"], index=0)
|
| 32 |
+
if selected_subtotals == "Player Totals":
|
| 33 |
+
data = data[~data.name.str.contains(" Totals")]
|
| 34 |
+
elif selected_subtotals == "Position Totals":
|
| 35 |
+
data = data[data.name.str.contains(" Totals")]
|
| 36 |
+
|
| 37 |
+
value_types = st.selectbox("Counts / Percent:", ["Counts", "Percent"], index=0)
|
| 38 |
+
if value_types == "Percent":
|
| 39 |
+
numerical_data = data.select_dtypes(include=np.number)
|
| 40 |
+
numerical_cols = numerical_data.columns
|
| 41 |
+
df_percent_values = numerical_data / data.groupby("TEAM").transform(sum).select_dtypes(include=np.number)
|
| 42 |
+
data.loc[:, numerical_cols] = df_percent_values
|
| 43 |
+
|
| 44 |
with st.container():
|
| 45 |
filtered_data = filter_dataframe(data)
|
| 46 |
st.dataframe(
|