Spaces:
Sleeping
Sleeping
Jon Solow
commited on
Commit
·
1d914b6
1
Parent(s):
2a4e60f
Add depth chart page
Browse files
src/pages/12_Depth_Charts.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
from config import DEFAULT_ICON
|
4 |
+
from shared_page import common_page_config
|
5 |
+
|
6 |
+
from streamlit_filter import filter_dataframe, get_multiselect_for_df_column
|
7 |
+
from queries.nflverse.github_data import get_depth_charts, get_current_tables, SEASON
|
8 |
+
|
9 |
+
|
10 |
+
hide_columns: list[str] = [
|
11 |
+
"last_name",
|
12 |
+
"first_name",
|
13 |
+
"football_name",
|
14 |
+
"gsis_id",
|
15 |
+
"elias_id",
|
16 |
+
]
|
17 |
+
|
18 |
+
|
19 |
+
def get_page():
|
20 |
+
page_title = f"Depth Charts - {SEASON}"
|
21 |
+
st.set_page_config(page_title=page_title, page_icon=DEFAULT_ICON, layout="wide")
|
22 |
+
common_page_config()
|
23 |
+
st.title(page_title)
|
24 |
+
|
25 |
+
table_name = f"depth_charts_depth_charts_{SEASON}"
|
26 |
+
current_tables_list = get_current_tables()
|
27 |
+
|
28 |
+
if table_name not in current_tables_list:
|
29 |
+
st.write("Data not loaded.")
|
30 |
+
st.write("Check loaded data [here](./Load_Data)")
|
31 |
+
return
|
32 |
+
data = get_depth_charts(SEASON)
|
33 |
+
|
34 |
+
week_selection = st.slider(
|
35 |
+
"Filter Week Range:",
|
36 |
+
min_value=data["week"].min(),
|
37 |
+
max_value=data["week"].max(),
|
38 |
+
value=(data["week"].min(), data["week"].max()),
|
39 |
+
step=1,
|
40 |
+
)
|
41 |
+
data = data[data["week"].between(*week_selection)]
|
42 |
+
|
43 |
+
data.drop(columns=hide_columns, inplace=True)
|
44 |
+
with st.container():
|
45 |
+
filtered_data = filter_dataframe(
|
46 |
+
data,
|
47 |
+
force_on=True,
|
48 |
+
force_on_columns=[
|
49 |
+
"club_code",
|
50 |
+
"position",
|
51 |
+
"depth_position",
|
52 |
+
"depth_team",
|
53 |
+
],
|
54 |
+
)
|
55 |
+
st.dataframe(
|
56 |
+
filtered_data,
|
57 |
+
hide_index=True,
|
58 |
+
# height=35 * (len(filtered_data) + 1) + 12,
|
59 |
+
use_container_width=False,
|
60 |
+
column_config={},
|
61 |
+
)
|
62 |
+
|
63 |
+
|
64 |
+
if __name__ == "__main__":
|
65 |
+
get_page()
|
src/queries/nflverse/github_data.py
CHANGED
@@ -64,6 +64,17 @@ def get_pbp_participation(season_int: int) -> pd.DataFrame:
|
|
64 |
return df
|
65 |
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
def get_nextgen_stats(season_int: int, stat_category: str) -> pd.DataFrame:
|
68 |
df = duckdb.sql(f"SELECT * from nextgen_stats_ngs_{stat_category} where season = {season_int}").df()
|
69 |
return df
|
|
|
64 |
return df
|
65 |
|
66 |
|
67 |
+
def get_depth_charts(season_int: int) -> pd.DataFrame:
|
68 |
+
df = duckdb.sql(
|
69 |
+
f"""
|
70 |
+
SELECT
|
71 |
+
*
|
72 |
+
from depth_charts_depth_charts_{season_int}
|
73 |
+
"""
|
74 |
+
).df()
|
75 |
+
return df
|
76 |
+
|
77 |
+
|
78 |
def get_nextgen_stats(season_int: int, stat_category: str) -> pd.DataFrame:
|
79 |
df = duckdb.sql(f"SELECT * from nextgen_stats_ngs_{stat_category} where season = {season_int}").df()
|
80 |
return df
|