sportowe_wizualizacja/Through_Ball.ipynb

513 lines
116 KiB
Plaintext
Raw Normal View History

2019-06-03 13:31:10 +02:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"done\n"
]
}
],
"source": [
"import json\n",
"import os\n",
"from pandas.io.json import json_normalize\n",
"import numpy as np\n",
"import seaborn as sns\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"from matplotlib.patches import Arc, Rectangle, ConnectionPatch\n",
"from matplotlib.offsetbox import OffsetImage\n",
"#import squarify\n",
"from functools import reduce\n",
"path = \"\"\"C:\\\\Users\\\\Koushik\\\\Downloads\\\\open-data-master\\\\open-data-master\\\\data\\\\my_events\\\\\"\"\"\n",
"Xg_req = pd.DataFrame(data=None)\n",
"for filename in (os.listdir(path)):\n",
" #print(filename)\n",
" \n",
" with open(\"%s\" % path + filename,encoding=\"utf8\") as data_file: \n",
" data = json.load(data_file)\n",
" df = pd.DataFrame(data=None)\n",
" \n",
" df = json_normalize(data, sep = \"_\")\n",
" \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",
" Xg_req = Xg_req.append(df,ignore_index=True,sort=False)\n",
" #df.drop(df.index, inplace=True)\n",
" \n",
"print(\"done\")\n",
"df = Xg_req"
]
},
{
"cell_type": "code",
2019-06-04 07:03:23 +02:00
"execution_count": 13,
2019-06-03 13:31:10 +02:00
"metadata": {},
2019-06-04 07:03:23 +02:00
"outputs": [
{
"data": {
"text/plain": [
"0 NaN\n",
"1 NaN\n",
"2 NaN\n",
"3 NaN\n",
"4 NaN\n",
"5 NaN\n",
"6 NaN\n",
"7 NaN\n",
"8 NaN\n",
"9 NaN\n",
"10 NaN\n",
"11 NaN\n",
"12 NaN\n",
"13 NaN\n",
"14 NaN\n",
"15 NaN\n",
"16 NaN\n",
"17 NaN\n",
"18 NaN\n",
"19 NaN\n",
"20 NaN\n",
"21 NaN\n",
"22 NaN\n",
"23 NaN\n",
"24 NaN\n",
"25 NaN\n",
"26 NaN\n",
"27 NaN\n",
"28 NaN\n",
"29 NaN\n",
" ... \n",
"179346 NaN\n",
"179347 NaN\n",
"179348 NaN\n",
"179349 NaN\n",
"179350 NaN\n",
"179351 NaN\n",
"179352 NaN\n",
"179353 NaN\n",
"179354 NaN\n",
"179355 NaN\n",
"179356 NaN\n",
"179357 NaN\n",
"179358 NaN\n",
"179359 NaN\n",
"179360 NaN\n",
"179361 NaN\n",
"179362 NaN\n",
"179363 NaN\n",
"179364 NaN\n",
"179365 NaN\n",
"179366 NaN\n",
"179367 NaN\n",
"179368 NaN\n",
"179369 NaN\n",
"179370 NaN\n",
"179371 NaN\n",
"179372 Free Kick\n",
"179373 NaN\n",
"179374 NaN\n",
"179375 NaN\n",
"Name: shot_type_name, Length: 179376, dtype: object"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
2019-06-03 13:31:10 +02:00
"source": [
"through_ball = df.query('pass_through_ball == True')"
]
},
{
"cell_type": "code",
2019-06-04 07:03:23 +02:00
"execution_count": 14,
2019-06-03 13:31:10 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2019-06-04 07:03:23 +02:00
"30\n",
"0\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",
2019-06-03 13:31:10 +02:00
"print(len(assist.index))\n",
"goal = assist.query('shot_outcome_id == 97')\n",
"#assist = df.query('pass_goal_assist == True')\n",
"print(len(goal.index))"
]
},
{
"cell_type": "code",
2019-06-04 07:03:23 +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",
" <th>27</th>\n",
" <td>95ffe924-77f3-40e2-afc6-23e5fed8865f</td>\n",
" <td>1</td>\n",
" <td>00:00:38.660</td>\n",
" <td>[44.0, 17.0]</td>\n",
" <td>[95.0, 23.0]</td>\n",
" <td>Francesca Kirby</td>\n",
" </tr>\n",
" <tr>\n",
" <th>257</th>\n",
" <td>ce817472-51c1-4b9a-89d5-2b929f422b2e</td>\n",
" <td>1</td>\n",
" <td>00:08:03.753</td>\n",
" <td>[89.0, 65.0]</td>\n",
" <td>[116.0, 55.0]</td>\n",
" <td>Nikita Parris</td>\n",
" </tr>\n",
" <tr>\n",
" <th>623</th>\n",
" <td>cf2ed5ec-1d2f-4746-a482-4ff7a1823adf</td>\n",
" <td>1</td>\n",
" <td>00:19:30.020</td>\n",
" <td>[39.0, 38.0]</td>\n",
" <td>[96.0, 42.0]</td>\n",
" <td>Ramona Bachmann</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1574</th>\n",
" <td>898b1dba-d2e6-431c-b830-4d897c946ad2</td>\n",
" <td>2</td>\n",
" <td>00:01:56.558</td>\n",
" <td>[41.0, 79.0]</td>\n",
" <td>[101.0, 47.0]</td>\n",
" <td>Ramona Bachmann</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3292</th>\n",
" <td>7799fb29-209f-4b3a-a73e-2c35f9d83c51</td>\n",
" <td>1</td>\n",
" <td>00:09:35.360</td>\n",
" <td>[74.0, 48.0]</td>\n",
" <td>[98.0, 32.0]</td>\n",
" <td>Mallory Weber</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" id period timestamp \\\n",
"27 95ffe924-77f3-40e2-afc6-23e5fed8865f 1 00:00:38.660 \n",
"257 ce817472-51c1-4b9a-89d5-2b929f422b2e 1 00:08:03.753 \n",
"623 cf2ed5ec-1d2f-4746-a482-4ff7a1823adf 1 00:19:30.020 \n",
"1574 898b1dba-d2e6-431c-b830-4d897c946ad2 2 00:01:56.558 \n",
"3292 7799fb29-209f-4b3a-a73e-2c35f9d83c51 1 00:09:35.360 \n",
"\n",
" location pass_end_location pass_recipient_name \n",
"27 [44.0, 17.0] [95.0, 23.0] Francesca Kirby \n",
"257 [89.0, 65.0] [116.0, 55.0] Nikita Parris \n",
"623 [39.0, 38.0] [96.0, 42.0] Ramona Bachmann \n",
"1574 [41.0, 79.0] [101.0, 47.0] Ramona Bachmann \n",
"3292 [74.0, 48.0] [98.0, 32.0] Mallory Weber "
]
},
2019-06-04 07:03:23 +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",
2019-06-04 07:03:23 +02:00
"execution_count": 15,
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",
" <th>199</th>\n",
" <td>c547c736-4bf5-484f-9360-463abb19e465</td>\n",
" <td>1</td>\n",
" <td>00:05:45.020</td>\n",
" <td>[104.0, 36.0]</td>\n",
" <td>[109.0, 29.0]</td>\n",
" <td>Millie Bright</td>\n",
" </tr>\n",
" <tr>\n",
" <th>746</th>\n",
" <td>e3eca08d-7c54-4c65-a19a-faa9708225b5</td>\n",
" <td>1</td>\n",
" <td>00:23:20.340</td>\n",
" <td>[111.0, 24.0]</td>\n",
" <td>[111.0, 35.0]</td>\n",
" <td>So-yun Ji</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1649</th>\n",
" <td>d48d70cf-3464-40c9-80c0-f81d7ce46b25</td>\n",
" <td>2</td>\n",
" <td>00:03:39.570</td>\n",
" <td>[108.0, 5.0]</td>\n",
" <td>[115.0, 43.0]</td>\n",
" <td>Nikita Parris</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2739</th>\n",
" <td>7f1fe749-1914-4f5d-8f0b-62c7c9f79196</td>\n",
" <td>2</td>\n",
" <td>00:40:33.251</td>\n",
" <td>[109.0, 48.0]</td>\n",
" <td>[97.0, 46.0]</td>\n",
" <td>Georgia Stanway</td>\n",
" </tr>\n",
" <tr>\n",
" <th>63663</th>\n",
" <td>59c55828-1423-4cf5-aef4-58f0cab1d9fe</td>\n",
" <td>2</td>\n",
" <td>00:06:57.202</td>\n",
" <td>[81.0, 28.0]</td>\n",
" <td>[87.0, 36.0]</td>\n",
" <td>Hayley Raso</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" id period timestamp \\\n",
"199 c547c736-4bf5-484f-9360-463abb19e465 1 00:05:45.020 \n",
"746 e3eca08d-7c54-4c65-a19a-faa9708225b5 1 00:23:20.340 \n",
"1649 d48d70cf-3464-40c9-80c0-f81d7ce46b25 2 00:03:39.570 \n",
"2739 7f1fe749-1914-4f5d-8f0b-62c7c9f79196 2 00:40:33.251 \n",
"63663 59c55828-1423-4cf5-aef4-58f0cab1d9fe 2 00:06:57.202 \n",
"\n",
" location pass_end_location pass_recipient_name \n",
"199 [104.0, 36.0] [109.0, 29.0] Millie Bright \n",
"746 [111.0, 24.0] [111.0, 35.0] So-yun Ji \n",
"1649 [108.0, 5.0] [115.0, 43.0] Nikita Parris \n",
"2739 [109.0, 48.0] [97.0, 46.0] Georgia Stanway \n",
"63663 [81.0, 28.0] [87.0, 36.0] Hayley Raso "
]
},
2019-06-04 07:03:23 +02:00
"execution_count": 15,
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",
2019-06-04 07:03:23 +02:00
"execution_count": 6,
2019-06-03 13:31:10 +02:00
"metadata": {},
"outputs": [],
"source": [
"def draw_pitch(ax):\n",
" # focus on only half of the pitch\n",
" #Pitch Outline & Centre Line\n",
" Pitch = Rectangle([0,0], width = 120, height = 80, fill = False)\n",
" #Left, Right Penalty Area and midline\n",
" LeftPenalty = Rectangle([0,22.3], width = 14.6, height = 35.3, fill = False)\n",
" RightPenalty = Rectangle([105.4,22.3], width = 14.6, height = 35.3, fill = False)\n",
" midline = ConnectionPatch([60,0], [60,80], \"data\", \"data\")\n",
"\n",
" #Left, Right 6-yard Box\n",
" LeftSixYard = Rectangle([0,32], width = 4.9, height = 16, fill = False)\n",
" RightSixYard = Rectangle([115.1,32], width = 4.9, height = 16, fill = False)\n",
"\n",
"\n",
" #Prepare Circles\n",
" centreCircle = plt.Circle((60,40),8.1,color=\"black\", fill = False)\n",
" centreSpot = plt.Circle((60,40),0.71,color=\"black\")\n",
" #Penalty spots and Arcs around penalty boxes\n",
" leftPenSpot = plt.Circle((9.7,40),0.71,color=\"black\")\n",
" rightPenSpot = plt.Circle((110.3,40),0.71,color=\"black\")\n",
" leftArc = Arc((9.7,40),height=16.2,width=16.2,angle=0,theta1=310,theta2=50,color=\"black\")\n",
" rightArc = Arc((110.3,40),height=16.2,width=16.2,angle=0,theta1=130,theta2=230,color=\"black\")\n",
" \n",
" element = [Pitch, LeftPenalty, RightPenalty, midline, LeftSixYard, RightSixYard, centreCircle, \n",
" centreSpot, rightPenSpot, leftPenSpot, leftArc, rightArc]\n",
" for i in element:\n",
" ax.add_patch(i)"
]
},
{
"cell_type": "code",
2019-06-04 07:03:23 +02:00
"execution_count": 8,
2019-06-03 13:31:10 +02:00
"metadata": {},
"outputs": [
{
"data": {
2019-06-04 07:03:23 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAawAAAEyCAYAAACmpOSfAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzsXXdYFNfXPkMXBaSpWAAVa8RujDXGGhv2Fms0GjUajSaxRWNvJLZfYo9iS9RoVOwt9tjA3kVBQOm9l93z/fE63y6wCwssIHrf59ln2d3ZmTszy3nvOec950rMTAICAgICAu86DIp6AAICAgICArpAEJaAgICAQLGAICwBAQEBgWIBQVgCAgICAsUCgrAEBAQEBIoFBGEJCAgICBQLCMISEBAQECgWEIQlICAgIFAsIAhLQEBAQKBYwKgwD2ZnZ8fOzs6FeUgBAQEBgXcY3t7e4cxsr8u2hUpYzs7O5OXlVZiHFBAQEBB4hyFJ0itdtxUhQQEBAQGBYgGdCEuSpO8kSXooSdIDSZL+kiTJTJKkypIkXZck6bkkSXskSTIp6MEKCAgICHy4yJGwJEmqQETfElFjZq5DRIZENJCIlhHRSmauRkRRRDSqIAcqICAgIPBhQ9eQoBERlZAkyYiIzIkoiIjaEtG+t59vI6Ke+h+egICAgIAAkKPogplf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GwqkEvoqs7Qx0OoBAWKC549Y+7Th7liReatW/Wr/HpXVYLp6cx//AEV5bBhzK9fF/wx4+KYjxxhnjiRuXp15pIlmSUJz1O
2019-06-03 13:31:10 +02:00
"text/plain": [
"<Figure size 504x360 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig=plt.figure() #set up the figures\n",
"fig.set_size_inches(7, 5)\n",
"ax=fig.add_subplot(1,1,1)\n",
"draw_pitch(ax) #overlay our different objects on the pitch\n",
"plt.ylim(-2, 82)\n",
"plt.xlim(-2, 122)\n",
"#plt.plot(x_axis,y_axis,'ro')\n",
"#plt.plot(x,y,'bo')\n",
"#plt.axis('off')\n",
"\n",
2019-06-04 07:03:23 +02:00
"for i in range(len(through_ball)):\n",
2019-06-03 13:31:10 +02:00
" # annotate draw an arrow from a current position to pass_end_location\n",
" ax.annotate(\"\", xy = (through_ball.iloc[i]['pass_end_location'][0], through_ball.iloc[i]['pass_end_location'][1]), xycoords = 'data',\n",
" xytext = (through_ball.iloc[i]['location'][0], through_ball.iloc[i]['location'][1]), textcoords = 'data',\n",
" arrowprops=dict(arrowstyle=\"->\",connectionstyle=\"arc3\", color = \"blue\"),)\n",
"\"\"\"\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",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAawAAAEyCAYAAACmpOS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lMAG09ZaSiKIpbKV0amDQJ6NSJ3pYVmjdnN/inngKioz1rnw0RYPdudp8vXhxo25Yp5p48n31I0JYdaIznzukEVjyssgDOAZhujNlpjPnGGJMTQBERiQCAuPvCjnY2xvQwxoQaY0LPWV3oVBRF8TRt2wJt2jiXUDFkCFCsGNC/v2dts9GpE238919m6+XKBXTp4rnz3bgBZMsWX2/lI+nsNqwIlj+AGgAmiEh1ANfgRPhPRCaLSLCIBBcqVCiNZiqKoniAjz9mB4evv7a2vTHAzJnMnJs+3bO2AcDkycDSpcBPP3EwZdu2FBRPYb9+dfYscOAA0LCh587nJFYE6ySAkyKyLe75IlDAzhhjigFA3L2HA6uKoihuJnt2YP584L33gB07rO2TOzfw/fdsrhsW5ln7Tp1iZuOXXwJHjgBPPunZ89kL1qpVnCzsSYF0klQFS0T+BXDCGGNbdWsCYD+A5QC6xb3WDcAd2MNEUZQMT/nyFISOHXnBtkKVKsD48UC7dsD5856x69AhCsYnnwDt2wO3bgGPPOKZc9mwT7jwsXAgYD1LsC+AOcaYPQCqARgJYBSAZsaYwwCaxT1XFEXJeHTqxJ6DPXtaX89q3563p5+23qPQKkeOAE2asNOGbc1q40YgMNC950mMzcO6eRNYu5benQ9hSbBEZFfcOlRVEWkrIv+JyAURaSIiFeLuIz1trKIoisf47DNg715g2jTr+3z0EcXq7bfdZ8fx4xSrt94CXnjBfce
"text/plain": [
"<Figure size 504x360 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig=plt.figure() #set up the figures\n",
"fig.set_size_inches(7, 5)\n",
"ax=fig.add_subplot(1,1,1)\n",
"draw_pitch(ax) #overlay our different objects on the pitch\n",
"plt.ylim(-2, 82)\n",
"plt.xlim(-2, 122)\n",
"#plt.plot(x_axis,y_axis,'ro')\n",
"#plt.plot(x,y,'bo')\n",
"#plt.axis('off')\n",
"\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",
"\n",
"plt.show() "
]
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",
"version": "3.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}