sportowe_wizualizacja/Through_Ball.ipynb

388 lines
81 KiB
Plaintext
Raw Permalink Normal View History

2019-06-03 13:31:10 +02:00
{
"cells": [
{
"cell_type": "code",
2020-05-18 10:25:48 +02:00
"execution_count": 1,
2019-06-03 13:31:10 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"done\n"
]
}
],
"source": [
"import json\n",
"import os\n",
"import numpy as np\n",
"import seaborn as sns\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
2020-05-18 10:25:48 +02:00
"import StatsbombPitch as sb\n",
2019-06-03 13:31:10 +02:00
"#import squarify\n",
"from functools import reduce\n",
2020-04-11 08:13:13 +02:00
"path = \"/home/kirugulige/Documents/Football-Analytics/open-data-master/data/events/\"\n",
2019-06-03 13:31:10 +02:00
"Xg_req = pd.DataFrame(data=None)\n",
2020-04-11 08:13:13 +02:00
"filename = '69275.json' \n",
"with open(\"%s\" % path + filename,encoding=\"utf8\") as data_file: \n",
" data = json.load(data_file)\n",
" df = pd.DataFrame(data=None)\n",
2019-06-03 13:31:10 +02:00
" \n",
2020-05-18 10:25:48 +02:00
" df = pd.json_normalize(data, sep = \"_\")\n",
2019-06-03 13:31:10 +02:00
" \n",
" #df = df[(df['type_name'] == \"Shot\")]\n",
" #df = df.loc[:,['location','shot_body_part_id','shot_end_location','shot_one_on_one','shot_technique_id','shot_type_id','under_pressure','shot_outcome_id']]\n",
" #print(df.shape)\n",
2020-04-11 08:13:13 +02:00
"Xg_req = Xg_req.append(df,ignore_index=True,sort=False)\n",
2019-06-03 13:31:10 +02:00
" #df.drop(df.index, inplace=True)\n",
" \n",
"print(\"done\")\n",
"df = Xg_req"
]
},
{
"cell_type": "code",
2020-05-18 10:25:48 +02:00
"execution_count": 2,
2019-06-03 13:31:10 +02:00
"metadata": {},
2020-04-11 08:13:13 +02:00
"outputs": [],
2019-06-03 13:31:10 +02:00
"source": [
"through_ball = df.query('pass_through_ball == True')"
]
},
{
"cell_type": "code",
2020-05-18 10:25:48 +02:00
"execution_count": 3,
2019-06-03 13:31:10 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2020-05-18 10:25:48 +02:00
"4\n"
2019-06-03 13:31:10 +02:00
]
}
],
"source": [
2019-06-04 07:03:23 +02:00
"assist = df.query('pass_goal_assist == True')\n",
2020-05-18 10:25:48 +02:00
"print(len(assist.index))"
2019-06-03 13:31:10 +02:00
]
},
{
"cell_type": "code",
2020-05-18 10:25:48 +02:00
"execution_count": 4,
2019-06-03 13:31:10 +02:00
"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>id</th>\n",
" <th>period</th>\n",
" <th>timestamp</th>\n",
" <th>location</th>\n",
" <th>pass_end_location</th>\n",
" <th>pass_recipient_name</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
2020-04-11 08:13:13 +02:00
" <th>280</th>\n",
" <td>1f6ef40d-cd32-4566-add6-f1558833d0c1</td>\n",
2019-06-03 13:31:10 +02:00
" <td>1</td>\n",
2020-04-11 08:13:13 +02:00
" <td>00:05:57.827</td>\n",
" <td>[81.5, 37.8]</td>\n",
" <td>[103.1, 33.4]</td>\n",
" <td>Pablo Daniel Osvaldo</td>\n",
2019-06-03 13:31:10 +02:00
" </tr>\n",
" <tr>\n",
2020-04-11 08:13:13 +02:00
" <th>604</th>\n",
" <td>4040c0ab-d934-469b-84f5-c595213b851b</td>\n",
2019-06-03 13:31:10 +02:00
" <td>1</td>\n",
2020-04-11 08:13:13 +02:00
" <td>00:13:56.420</td>\n",
" <td>[48.2, 57.4]</td>\n",
" <td>[85.5, 38.3]</td>\n",
" <td>Pablo Daniel Osvaldo</td>\n",
2019-06-03 13:31:10 +02:00
" </tr>\n",
" <tr>\n",
2020-04-11 08:13:13 +02:00
" <th>794</th>\n",
" <td>7dbe04a8-41c5-4ea8-bfa1-892fe23a72e6</td>\n",
2019-06-03 13:31:10 +02:00
" <td>1</td>\n",
2020-04-11 08:13:13 +02:00
" <td>00:18:30.829</td>\n",
" <td>[66.8, 46.7]</td>\n",
" <td>[93.5, 38.5]</td>\n",
" <td>Pedro Eliezer Rodríguez Ledesma</td>\n",
2019-06-03 13:31:10 +02:00
" </tr>\n",
" <tr>\n",
2020-04-11 08:13:13 +02:00
" <th>840</th>\n",
" <td>3a7da0a1-e9c4-40a1-9702-e99c5ace03c2</td>\n",
" <td>1</td>\n",
" <td>00:20:46.623</td>\n",
" <td>[66.0, 56.5]</td>\n",
" <td>[105.5, 34.7]</td>\n",
" <td>José María Callejón Bueno</td>\n",
2019-06-03 13:31:10 +02:00
" </tr>\n",
" <tr>\n",
2020-04-11 08:13:13 +02:00
" <th>962</th>\n",
" <td>2bc53e64-664a-4f83-9d0c-6b046d91a7d9</td>\n",
2019-06-03 13:31:10 +02:00
" <td>1</td>\n",
2020-04-11 08:13:13 +02:00
" <td>00:23:55.494</td>\n",
" <td>[81.5, 28.1]</td>\n",
" <td>[94.2, 31.7]</td>\n",
" <td>David Villa Sánchez</td>\n",
2019-06-03 13:31:10 +02:00
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
2020-04-11 08:13:13 +02:00
" id period timestamp location \\\n",
"280 1f6ef40d-cd32-4566-add6-f1558833d0c1 1 00:05:57.827 [81.5, 37.8] \n",
"604 4040c0ab-d934-469b-84f5-c595213b851b 1 00:13:56.420 [48.2, 57.4] \n",
"794 7dbe04a8-41c5-4ea8-bfa1-892fe23a72e6 1 00:18:30.829 [66.8, 46.7] \n",
"840 3a7da0a1-e9c4-40a1-9702-e99c5ace03c2 1 00:20:46.623 [66.0, 56.5] \n",
"962 2bc53e64-664a-4f83-9d0c-6b046d91a7d9 1 00:23:55.494 [81.5, 28.1] \n",
2019-06-03 13:31:10 +02:00
"\n",
2020-04-11 08:13:13 +02:00
" pass_end_location pass_recipient_name \n",
"280 [103.1, 33.4] Pablo Daniel Osvaldo \n",
"604 [85.5, 38.3] Pablo Daniel Osvaldo \n",
"794 [93.5, 38.5] Pedro Eliezer Rodríguez Ledesma \n",
"840 [105.5, 34.7] José María Callejón Bueno \n",
"962 [94.2, 31.7] David Villa Sánchez "
2019-06-03 13:31:10 +02:00
]
},
2020-05-18 10:25:48 +02:00
"execution_count": 4,
2019-06-03 13:31:10 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"through_ball= through_ball[[\"id\", \"period\", \"timestamp\", \"location\", \"pass_end_location\", \"pass_recipient_name\"]]\n",
"through_ball.head()"
]
},
{
"cell_type": "code",
2020-05-18 10:25:48 +02:00
"execution_count": 5,
2019-06-03 13:31:10 +02:00
"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>id</th>\n",
" <th>period</th>\n",
" <th>timestamp</th>\n",
" <th>location</th>\n",
" <th>pass_end_location</th>\n",
" <th>pass_recipient_name</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
2020-04-11 08:13:13 +02:00
" <th>794</th>\n",
" <td>7dbe04a8-41c5-4ea8-bfa1-892fe23a72e6</td>\n",
2019-06-03 13:31:10 +02:00
" <td>1</td>\n",
2020-04-11 08:13:13 +02:00
" <td>00:18:30.829</td>\n",
" <td>[66.8, 46.7]</td>\n",
" <td>[93.5, 38.5]</td>\n",
" <td>Pedro Eliezer Rodríguez Ledesma</td>\n",
2019-06-03 13:31:10 +02:00
" </tr>\n",
" <tr>\n",
2020-04-11 08:13:13 +02:00
" <th>2436</th>\n",
" <td>9810ac65-15b8-4736-a09e-08f7faaff01d</td>\n",
2019-06-03 13:31:10 +02:00
" <td>2</td>\n",
2020-04-11 08:13:13 +02:00
" <td>00:17:04.830</td>\n",
" <td>[52.7, 63.4]</td>\n",
" <td>[84.2, 57.1]</td>\n",
" <td>Pablo Daniel Osvaldo</td>\n",
2019-06-03 13:31:10 +02:00
" </tr>\n",
" <tr>\n",
2020-04-11 08:13:13 +02:00
" <th>2935</th>\n",
" <td>7269b3a6-43d7-45bc-8823-bcfd1542ad45</td>\n",
2019-06-03 13:31:10 +02:00
" <td>2</td>\n",
2020-04-11 08:13:13 +02:00
" <td>00:30:03.492</td>\n",
" <td>[64.4, 33.8]</td>\n",
" <td>[79.4, 25.5]</td>\n",
" <td>David Villa Sánchez</td>\n",
2019-06-03 13:31:10 +02:00
" </tr>\n",
" <tr>\n",
2020-04-11 08:13:13 +02:00
" <th>3344</th>\n",
" <td>dc1b453d-6e7e-49b1-ad88-79525e8223f9</td>\n",
2019-06-03 13:31:10 +02:00
" <td>2</td>\n",
2020-04-11 08:13:13 +02:00
" <td>00:38:47.689</td>\n",
" <td>[70.1, 30.6]</td>\n",
" <td>[98.0, 23.3]</td>\n",
" <td>David Villa Sánchez</td>\n",
2019-06-03 13:31:10 +02:00
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
2020-04-11 08:13:13 +02:00
" id period timestamp \\\n",
"794 7dbe04a8-41c5-4ea8-bfa1-892fe23a72e6 1 00:18:30.829 \n",
"2436 9810ac65-15b8-4736-a09e-08f7faaff01d 2 00:17:04.830 \n",
"2935 7269b3a6-43d7-45bc-8823-bcfd1542ad45 2 00:30:03.492 \n",
"3344 dc1b453d-6e7e-49b1-ad88-79525e8223f9 2 00:38:47.689 \n",
2019-06-03 13:31:10 +02:00
"\n",
2020-04-11 08:13:13 +02:00
" location pass_end_location pass_recipient_name \n",
"794 [66.8, 46.7] [93.5, 38.5] Pedro Eliezer Rodríguez Ledesma \n",
"2436 [52.7, 63.4] [84.2, 57.1] Pablo Daniel Osvaldo \n",
"2935 [64.4, 33.8] [79.4, 25.5] David Villa Sánchez \n",
"3344 [70.1, 30.6] [98.0, 23.3] David Villa Sánchez "
2019-06-03 13:31:10 +02:00
]
},
2020-05-18 10:25:48 +02:00
"execution_count": 5,
2019-06-03 13:31:10 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"assist= assist[[\"id\", \"period\", \"timestamp\", \"location\", \"pass_end_location\", \"pass_recipient_name\"]]\n",
"assist.head()"
]
},
{
"cell_type": "code",
2020-05-18 10:25:48 +02:00
"execution_count": 6,
2019-06-03 13:31:10 +02:00
"metadata": {},
"outputs": [
{
"data": {
2020-05-18 10:25:48 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmsAAAGRCAYAAAA6rfQGAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzs3Xl8XHW9//HXOWcyM5kkk61pC7S0hbK1dKVlKaW0BQRErXjVH4uiuOv13it65brdy+Ne7vWCet2u4nbdr4B6FauyCUIpLXSlC6UtdEvpQpo9k8x+zvf7++ObdE3aJJ1kzmQ+z8fDhzpJpt9MZua857t8PpbWGiGEEEII4U92vgcghBBCCCH6JmFNCCGEEMLHJKwJIYQQQviYhDUhhBBCCB+TsCaEEEII4WMS1oQQQgghfCwwnP/YmbcFG4Axw/lvCiGEEEL4ycEHM9ZAvn+4Z9YkqAkhhBBCDIAsgwohhBBC+JiENSGEEEIIHxvWPWvH2/u9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sDIBt61RJKGoAluxBFbZCCGEEHmksubEZ2Knouwim6p5EtR6qIw5QND6Vw+Uaa1VdXmg6IMagN6k+I4HnwD+DVgEPOiZ24tFT2B9JAFp4JEEhNcokvVevoeWczKzJoQQeeIlNK3LXdx2qJzrEJksn597pPZ3F7dNQdmFNuXTbCkEfJRYAn4NpIA7um+b3317JH/DGlZ6k+JBD8JAM0cC682bFIyw2TUJa0IIkQfZdlOaQ2egeoG0Q+rhJTWx9aYIcKAKqq9yCNbKY3O80hD8Nm1m1c7vvm0FZimwWMQSMBa4ErgUeIK
2019-06-03 13:31:10 +02:00
"text/plain": [
2020-05-18 10:25:48 +02:00
"<Figure size 748.8x489.6 with 1 Axes>"
2019-06-03 13:31:10 +02:00
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
2020-05-18 10:25:48 +02:00
"sb.sb_pitch(\"#195905\",\"#faf0e6\",\"horizontal\",\"full\")\n",
"plt.gca().invert_yaxis() #overlay our different objects on the pitch\n",
"#plt.ylim(-2, 82)\n",
"#plt.xlim(-2, 122)\n",
2019-06-03 13:31:10 +02:00
"#plt.plot(x_axis,y_axis,'ro')\n",
"#plt.plot(x,y,'bo')\n",
2020-05-18 10:25:48 +02:00
"plt.axis('off')\n",
2019-06-04 07:03:23 +02:00
"for i in range(len(through_ball)):\n",
2020-04-11 08:13:13 +02:00
" x = through_ball.iloc[i]['pass_end_location'][0]\n",
" y = through_ball.iloc[i]['pass_end_location'][1]\n",
" xe = through_ball.iloc[i]['location'][0]\n",
" ye = through_ball.iloc[i]['location'][0]\n",
2020-05-18 10:25:48 +02:00
" plt.scatter(x,y,color=\"red\",edgecolors=\"black\",zorder=10,alpha=1)\n",
" plt.plot([x,xe],[y,ye],zorder=11,alpha=1,color=\"black\")\n",
2020-04-11 08:13:13 +02:00
"\n",
2019-06-03 13:31:10 +02:00
"\"\"\"\n",
"for i in range(len(assist)):\n",
" # annotate draw an arrow from a current position to pass_end_location\n",
" ax.annotate(\"\", xy = (assist.iloc[i]['pass_end_location'][0], assist.iloc[i]['pass_end_location'][1]), xycoords = 'data',\n",
" xytext = (assist.iloc[i]['location'][0], assist.iloc[i]['location'][1]), textcoords = 'data',\n",
" arrowprops=dict(arrowstyle=\"->\",connectionstyle=\"arc3\", color = \"red\"),)\n",
2019-06-04 07:03:23 +02:00
"\"\"\"\n",
2019-06-03 13:31:10 +02:00
"\n",
"plt.show()"
]
2019-06-04 07:03:23 +02:00
},
{
"cell_type": "code",
2020-05-18 10:25:48 +02:00
"execution_count": 7,
2019-06-04 07:03:23 +02:00
"metadata": {},
"outputs": [
{
"data": {
2020-05-18 10:25:48 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmsAAAGRCAYAAAA6rfQGAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3Xl8VPW9//H395yZzJKNLWwGCBBEg8gi2LpW7SItKrW37QXtZu2u91fp4rW9tr332vaq9dbaerXV3q5XoXaxaLFaW0ULVgHZxIiyBQgKBJBMkplMkjnn98ckkShbksmcMzOv533ch0hh5pORYV75nnO+x7iuKwAAAPiT5fUAAAAAODpiDQAAwMeINQAAAB8j1gAAAHyMWAMAAPAxYg0AAMDHAtl8stFXFO2RNCKbzwkAAOAnr97fZnrz67O9skaoAQAA9AKHQQEAAHyMWAMAAPCxrJ6z9mYLzl2gebPneTkCgAJSVVElSaprqPN0DgCFY8mqJVq0fFG/HsPTlbV5s+epprLGyxEAFJBoKKpoKOr1GAAKRE1lTUYWpTxdWZOk2vpazb99vtdjACgAixculiT+zgGQFV1/5/QX56wBAAD4GLEGAADgY8QaAACAjxFrAAAAPkasAQAA+BixBgAA4GPEGgAAgI8RawAAAD5GrAEAAPgYsQYAAOBjxBoAAICPEWsAAAA+RqwBAAD4GL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lLNnT9u6fxxi6Q3teIuSRMknd757+dKisWlaJ+eHfA/Yg0AsqxohJFdmr7QIDrenwc43hJsRio9/a3BVjb
2019-06-04 07:03:23 +02:00
"text/plain": [
2020-05-18 10:25:48 +02:00
"<Figure size 748.8x489.6 with 1 Axes>"
2019-06-04 07:03:23 +02:00
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
2020-05-18 10:25:48 +02:00
"sb.sb_pitch(\"#195905\",\"#faf0e6\",\"horizontal\",\"full\")\n",
"plt.gca().invert_yaxis() #overlay our different objects on the pitch\n",
"#plt.ylim(-2, 82)\n",
"#plt.xlim(-2, 122)\n",
2019-06-04 07:03:23 +02:00
"#plt.plot(x_axis,y_axis,'ro')\n",
"#plt.plot(x,y,'bo')\n",
"\n",
2020-05-18 10:25:48 +02:00
"plt.gca().invert_yaxis()\n",
2019-06-04 07:03:23 +02:00
"for i in range(len(assist)):\n",
2020-04-11 08:13:13 +02:00
" x = assist.iloc[i]['pass_end_location'][0]\n",
" y = assist.iloc[i]['pass_end_location'][1]\n",
" xe = assist.iloc[i]['location'][0]\n",
" ye = assist.iloc[i]['location'][0]\n",
2020-05-18 10:25:48 +02:00
" plt.scatter(x,y,color=\"red\",edgecolors=\"black\",zorder=10,alpha=1)\n",
" plt.plot([x,xe],[y,ye],zorder=11,alpha=1,color=\"black\")\n",
2019-06-04 07:03:23 +02:00
"\n",
2020-04-11 08:13:13 +02:00
"\n",
"plt.show()"
2019-06-04 07:03:23 +02:00
]
2019-06-03 13:31:10 +02:00
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2020-04-11 08:13:13 +02:00
"version": "3.6.9"
2019-06-03 13:31:10 +02:00
}
},
"nbformat": 4,
"nbformat_minor": 2
}