Skip to content

Commit

Permalink
Update sportec docs
Browse files Browse the repository at this point in the history
  • Loading branch information
koenvo committed Jul 30, 2023
1 parent d8eeb5e commit edfb935
Showing 1 changed file with 268 additions and 16 deletions.
284 changes: 268 additions & 16 deletions docs/getting-started/sportec.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"source": [
"# Sportec\n",
"\n",
"## Load local files"
"## Load local event files"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "e9adb7cb",
"id": "4f6455fb",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -77,7 +77,7 @@
" <td>38.71</td>\n",
" <td>DFL-OBJ-0000ZS</td>\n",
" <td>KICK_OFF</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
Expand All @@ -97,8 +97,8 @@
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>DFL-OBJ-002G3I</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>None</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
Expand All @@ -119,7 +119,7 @@
" <td>28.58</td>\n",
" <td>DFL-OBJ-0027B9</td>\n",
" <td>THROW_IN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
Expand All @@ -138,8 +138,8 @@
" <td>28.58</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>None</td>\n",
" <td>RIGHT_FOOT</td>\n",
" </tr>\n",
" <tr>\n",
Expand All @@ -160,8 +160,8 @@
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>None</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
Expand Down Expand Up @@ -190,11 +190,11 @@
"4 8.72 4.21 NaN NaN \n",
"\n",
" receiver_player_id set_piece_type body_part_type \n",
"0 DFL-OBJ-0000ZS KICK_OFF NaN \n",
"1 DFL-OBJ-002G3I NaN NaN \n",
"2 DFL-OBJ-0027B9 THROW_IN NaN \n",
"3 NaN NaN RIGHT_FOOT \n",
"4 None NaN NaN "
"0 DFL-OBJ-0000ZS KICK_OFF None \n",
"1 DFL-OBJ-002G3I None None \n",
"2 DFL-OBJ-0027B9 THROW_IN None \n",
"3 None None RIGHT_FOOT \n",
"4 None None None "
]
},
"execution_count": 1,
Expand All @@ -205,7 +205,7 @@
"source": [
"from kloppy import sportec\n",
"\n",
"dataset = sportec.load(\n",
"dataset = sportec.load_event(\n",
" event_data=\"../../kloppy/tests/files/sportec_events.xml\",\n",
" meta_data=\"../../kloppy/tests/files/sportec_meta.xml\",\n",
" \n",
Expand All @@ -216,6 +216,258 @@
"\n",
"dataset.to_df().head()"
]
},
{
"cell_type": "markdown",
"id": "81989fc6",
"metadata": {},
"source": [
"# Load local tracking files"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "958f17ee",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>period_id</th>\n",
" <th>timestamp</th>\n",
" <th>frame_id</th>\n",
" <th>ball_state</th>\n",
" <th>ball_owning_team_id</th>\n",
" <th>ball_x</th>\n",
" <th>ball_y</th>\n",
" <th>ball_z</th>\n",
" <th>ball_speed</th>\n",
" <th>DFL-OBJ-002G3I_x</th>\n",
" <th>...</th>\n",
" <th>DFL-OBJ-002G3I_d</th>\n",
" <th>DFL-OBJ-002G3I_s</th>\n",
" <th>DFL-OBJ-002G5S_x</th>\n",
" <th>DFL-OBJ-002G5S_y</th>\n",
" <th>DFL-OBJ-002G5S_d</th>\n",
" <th>DFL-OBJ-002G5S_s</th>\n",
" <th>DFL-OBJ-002FVJ_x</th>\n",
" <th>DFL-OBJ-002FVJ_y</th>\n",
" <th>DFL-OBJ-002FVJ_d</th>\n",
" <th>DFL-OBJ-002FVJ_s</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>0.00</td>\n",
" <td>10000</td>\n",
" <td>dead</td>\n",
" <td>DFL-CLU-000004</td>\n",
" <td>2.69</td>\n",
" <td>0.26</td>\n",
" <td>0.06</td>\n",
" <td>0.00</td>\n",
" <td>0.35</td>\n",
" <td>...</td>\n",
" <td>None</td>\n",
" <td>0.00</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>0.04</td>\n",
" <td>10001</td>\n",
" <td>alive</td>\n",
" <td>DFL-CLU-00000A</td>\n",
" <td>3.41</td>\n",
" <td>0.26</td>\n",
" <td>0.08</td>\n",
" <td>65.59</td>\n",
" <td>0.34</td>\n",
" <td>...</td>\n",
" <td>None</td>\n",
" <td>1.74</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1</td>\n",
" <td>0.08</td>\n",
" <td>10002</td>\n",
" <td>alive</td>\n",
" <td>DFL-CLU-000004</td>\n",
" <td>4.22</td>\n",
" <td>0.33</td>\n",
" <td>0.09</td>\n",
" <td>65.16</td>\n",
" <td>0.32</td>\n",
" <td>...</td>\n",
" <td>None</td>\n",
" <td>1.76</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1</td>\n",
" <td>0.12</td>\n",
" <td>10003</td>\n",
" <td>alive</td>\n",
" <td>DFL-CLU-000004</td>\n",
" <td>5.02</td>\n",
" <td>0.38</td>\n",
" <td>0.09</td>\n",
" <td>74.34</td>\n",
" <td>0.31</td>\n",
" <td>...</td>\n",
" <td>None</td>\n",
" <td>1.78</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1</td>\n",
" <td>0.16</td>\n",
" <td>10004</td>\n",
" <td>alive</td>\n",
" <td>DFL-CLU-000004</td>\n",
" <td>5.79</td>\n",
" <td>0.44</td>\n",
" <td>0.08</td>\n",
" <td>73.58</td>\n",
" <td>0.29</td>\n",
" <td>...</td>\n",
" <td>None</td>\n",
" <td>1.80</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 21 columns</p>\n",
"</div>"
],
"text/plain": [
" period_id timestamp frame_id ball_state ball_owning_team_id ball_x \\\n",
"0 1 0.00 10000 dead DFL-CLU-000004 2.69 \n",
"1 1 0.04 10001 alive DFL-CLU-00000A 3.41 \n",
"2 1 0.08 10002 alive DFL-CLU-000004 4.22 \n",
"3 1 0.12 10003 alive DFL-CLU-000004 5.02 \n",
"4 1 0.16 10004 alive DFL-CLU-000004 5.79 \n",
"\n",
" ball_y ball_z ball_speed DFL-OBJ-002G3I_x ... DFL-OBJ-002G3I_d \\\n",
"0 0.26 0.06 0.00 0.35 ... None \n",
"1 0.26 0.08 65.59 0.34 ... None \n",
"2 0.33 0.09 65.16 0.32 ... None \n",
"3 0.38 0.09 74.34 0.31 ... None \n",
"4 0.44 0.08 73.58 0.29 ... None \n",
"\n",
" DFL-OBJ-002G3I_s DFL-OBJ-002G5S_x DFL-OBJ-002G5S_y DFL-OBJ-002G5S_d \\\n",
"0 0.00 NaN NaN None \n",
"1 1.74 NaN NaN None \n",
"2 1.76 NaN NaN None \n",
"3 1.78 NaN NaN None \n",
"4 1.80 NaN NaN None \n",
"\n",
" DFL-OBJ-002G5S_s DFL-OBJ-002FVJ_x DFL-OBJ-002FVJ_y DFL-OBJ-002FVJ_d \\\n",
"0 NaN NaN NaN None \n",
"1 NaN NaN NaN None \n",
"2 NaN NaN NaN None \n",
"3 NaN NaN NaN None \n",
"4 NaN NaN NaN None \n",
"\n",
" DFL-OBJ-002FVJ_s \n",
"0 NaN \n",
"1 NaN \n",
"2 NaN \n",
"3 NaN \n",
"4 NaN \n",
"\n",
"[5 rows x 21 columns]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from kloppy import sportec\n",
"\n",
"\n",
"dataset = sportec.load_tracking(\n",
" raw_data=\"../../kloppy/tests/files/sportec_positional.xml\",\n",
" meta_data=\"../../kloppy/tests/files/sportec_meta.xml\",\n",
" \n",
" # Optional arguments\n",
" coordinates=\"sportec\",\n",
" only_alive=False\n",
")\n",
"\n",
"dataset.to_df().head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "366f1126",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit edfb935

Please sign in to comment.