import pandas as pd # pip install pandas openpyxl
import plotly.express as px # pip install plotly-express
import streamlit as st # pip install streamlit
from openpyxl import load_workbook
st.set_page_config(page_title="GPS Data Summerhill 2025", page_icon=":bar_chart:", layout="wide")
@st.cache_data
def get_data_from_excel():
#df = load_workbook(filename="GPS-Data.csv",data_only=True)
df = pd.read_excel("GPS-Data.xlsx")
return df
df= get_data_from_excel()
# print (df)
#st.dataframe(df)
st.sidebar.header("Please Filter Here:")
player = st.sidebar.multiselect(
"Select the Player:",
options=df["Player_Name"].unique(),
default=df["Player_Name"].unique()
)
period = st.sidebar.multiselect(
"Select the Time Period:",
options=df["Drill_Title"].unique(),
default=df["Drill_Title"].unique()
)
session = st.sidebar.multiselect(
"Select the Session:",
options=df["Session_Name"].unique(),
default=df["Session_Name"].unique()
)
df_selection = df.query ("Player_Name == @player & Drill_Title== @period & Session_Name ==@session")
st.dataframe(df_selection)
# ---- MAINPAGE ----
st.title(":bar_chart: Total Distance Dashboard")
st.markdown("##")
column1, column2, column3, column4, column5 = st.columns(5)
total_distance = int(df_selection["Total_Distance"].sum())
total_hsr = int(df_selection["High_Speed_Running"].sum())
total_sprint = int(df_selection["Sprint_Distance"].sum())
max_speed = float(df_selection["Max_Speed"].max())
average_distance = int(df_selection["Total_Distance"].mean())
average_hsr = int(df_selection["High_Speed_Running"].mean())
average_sprint = int(df_selection["Sprint_Distance"].mean())
with column1:
st.subheader("Total Distance:")
st.subheader(f"{total_distance:,} meters")
st.subheader(" ")
st.subheader("Average:")
st.subheader(f"{average_distance:,} meters")
with column2:
st.subheader("HSR:")
st.subheader(f"{total_hsr:,} meters")
st.subheader(" ")
st.subheader("Average:")
st.subheader(average_hsr,": meters")
with column3:
st.subheader("Sprint Distance:")
st.subheader(f"{total_sprint:,} meters")
st.subheader(" ")
st.subheader("Average:")
st.subheader(average_sprint,": meters")
with column4:
st.subheader("Max Speed:")
st.subheader(max_speed, "meters")
st.markdown("""---""")
# Total Distance [BAR CHART]
total_distance_graph = df_selection.groupby(by=["Player_Name"])[["Total_Distance"]].sum().sort_values(by="Total_Distance")
fig_distance_graph = px.bar(
total_distance_graph,
x="Total_Distance",
y=total_distance_graph.index,
orientation="h",
title="<b>Total Distance</b>",
color_discrete_sequence=["#0000ff"],
template="plotly_white",
)
fig_distance_graph.update_layout(
plot_bgcolor="rgba(0,0,0,0)",
xaxis=(dict(showgrid=False))
)
# Total HSR [BAR CHART]
total_hsr_graph = df_selection.groupby(by=["Player_Name"])[["High_Speed_Running"]].sum().sort_values(by="High_Speed_Running")
fig_hsr_graph = px.bar(
total_hsr_graph,
y="High_Speed_Running",
x=total_hsr_graph.index,
orientation="v",
title="<b>Total High Speed Running</b>",
color_discrete_sequence=["#0000ff"],
template="simple_white",
)
fig_hsr_graph.update_layout(
plot_bgcolor="rgba(0,0,0,0)",
#xaxis=dict(tickmode="linear"),
xaxis=(dict(showgrid=False))
)
#fig_hsr_graph.update(texttemplate='High_Speed_Running', textposition='outside')
left_column, right_column = st.columns(2)
left_column.plotly_chart(fig_distance_graph, use_container_width=True)
right_column.plotly_chart(fig_hsr_graph, use_container_width=True)
st.markdown("""---""")