Skip to content

Commit

Permalink
Merge pull request #616 from plotly/fix-soccer
Browse files Browse the repository at this point in the history
Fix soccer app bug
  • Loading branch information
Xing Han Lu authored Apr 21, 2021
2 parents d96997b + db301db commit c9c676a
Show file tree
Hide file tree
Showing 5 changed files with 448,360 additions and 530,490 deletions.
10 changes: 5 additions & 5 deletions apps/dash-soccer-analytics/TrackingDataPreProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
import numpy as np

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

raw_df2 = pd.read_csv("data/Sample_Game_2_RawTrackingData_Home_Team.csv")
raw_df2 = pd.read_csv("data/source/Sample_Game_2_RawTrackingData_Home_Team.csv")
raw_df2 = raw_df2.iloc[::7, :]

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

Expand Down
2 changes: 1 addition & 1 deletion apps/dash-soccer-analytics/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
dbc.Select(
id="event-file",
options=[{"label": i, "value": i} for i in event_files],
value=event_files[0],
value=None,
placeholder="Select a file for events",
),
]
Expand Down
Loading

0 comments on commit c9c676a

Please sign in to comment.