Py.Cafe

dermot.clarke68/

gps-data-analysis

GPS Data Analysis

DocsPricing
  • GPS-Data.xlsx
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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("""---""")