Skip to content

Commit c9c676a

Browse files
author
Xing Han Lu
authored
Merge pull request #616 from plotly/fix-soccer
Fix soccer app bug
2 parents d96997b + db301db commit c9c676a

File tree

5 files changed

+448360
-530490
lines changed

5 files changed

+448360
-530490
lines changed

apps/dash-soccer-analytics/TrackingDataPreProcessing.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
import numpy as np
33

44
# raw_df = pd.read_csv(cv_file, names=header_list, error_bad_lines=False, dtype=str)
5-
raw_df1 = pd.read_csv("data/Sample_Game_2_RawTrackingData_Away_Team.csv")
5+
raw_df1 = pd.read_csv("data/source/Sample_Game_2_RawTrackingData_Away_Team.csv")
66
# sample every 5th row
77
raw_df1 = raw_df1.iloc[::7, :]
88

9-
raw_df2 = pd.read_csv("data/Sample_Game_2_RawTrackingData_Home_Team.csv")
9+
raw_df2 = pd.read_csv("data/source/Sample_Game_2_RawTrackingData_Home_Team.csv")
1010
raw_df2 = raw_df2.iloc[::7, :]
1111

1212
column = 1
1313
df = pd.DataFrame(columns=["half", "frame", "time", "x", "y"])
1414
# x range needs adjusted depending on how many columns there are. Should really calculate this not eyeball items
15-
# and do it manually. But hey it's just for a demo not ongoing
15+
# and do it manually.
1616
for x in range(0, 13):
1717
column = column + 2
1818
df_temp = raw_df1.iloc[:, [0, 1, 2, column, column + 1]].copy()
@@ -35,8 +35,8 @@
3535
df_temp2["jersey_number"] = raw_df2.columns[column]
3636
df2 = pd.concat([df2, df_temp2]).reset_index(drop=True)
3737
df2["team"] = "Home"
38-
df2.loc[df2["x"].isna(), "x"] = 0.5
39-
df2.loc[df2["y"].isna(), "y"] = 0.5
38+
df2.loc[df2["x"].isna(), "x"] = None
39+
df2.loc[df2["y"].isna(), "y"] = None
4040
df2 = df2[df2["x"].notna()]
4141
df2.drop(df2.loc[df2["half"] == "Period"].index, inplace=True)
4242

apps/dash-soccer-analytics/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
dbc.Select(
4141
id="event-file",
4242
options=[{"label": i, "value": i} for i in event_files],
43-
value=event_files[0],
43+
value=None,
4444
placeholder="Select a file for events",
4545
),
4646
]

0 commit comments

Comments
 (0)