{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "f5e5541b",
"metadata": {
"nbsphinx": "hidden",
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"env: SOCCERDATA_LOGLEVEL=ERROR\n",
"env: SOCCERDATA_NOCACHE=False\n",
"env: SOCCERDATA_NOSTORE=False\n"
]
}
],
"source": [
"%env SOCCERDATA_LOGLEVEL=ERROR\n",
"%env SOCCERDATA_NOCACHE=False\n",
"%env SOCCERDATA_NOSTORE=False"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "2454afe6",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import soccerdata as sd"
]
},
{
"cell_type": "markdown",
"id": "b5784f2d",
"metadata": {},
"source": [
"# Understat"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "8dab5be9",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Provides pd.DataFrames from data at https://understat.com.\n",
"\n",
" Data will be downloaded as necessary and cached locally in\n",
" ``~/soccerdata/data/Understat``.\n",
"\n",
" Parameters\n",
" ----------\n",
" proxy : 'tor' or dict or list(dict) or callable, optional\n",
" Use a proxy to hide your IP address. Valid options are:\n",
" - \"tor\": Uses the Tor network. Tor should be running in\n",
" the background on port 9050.\n",
" - dict: A dictionary with the proxy to use. The dict should be\n",
" a mapping of supported protocols to proxy addresses. For example::\n",
"\n",
" {\n",
" 'http': 'http://10.10.1.10:3128',\n",
" 'https': 'http://10.10.1.10:1080',\n",
" }\n",
"\n",
" - list(dict): A list of proxies to choose from. A different proxy will\n",
" be selected from this list after failed requests, allowing rotating\n",
" proxies.\n",
" - callable: A function that returns a valid proxy. This function will\n",
" be called after failed requests, allowing rotating proxies.\n",
" no_cache : bool\n",
" If True, will not use cached data.\n",
" no_store : bool\n",
" If True, will not store downloaded data.\n",
" data_dir : Path\n",
" Path to directory where data will be cached.\n",
" \n"
]
}
],
"source": [
"understat = sd.Understat(leagues=\"ENG-Premier League\", seasons=\"2015/2016\")\n",
"print(understat.__doc__)"
]
},
{
"cell_type": "markdown",
"id": "f791f100",
"metadata": {},
"source": [
"## Leagues"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "4dc08db7",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" league_id | \n",
" url | \n",
"
\n",
" \n",
" | league | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | ENG-Premier League | \n",
" 1 | \n",
" https://understat.com/league/EPL | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" league_id url\n",
"league \n",
"ENG-Premier League 1 https://understat.com/league/EPL"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"leagues = understat.read_leagues()\n",
"leagues.head()"
]
},
{
"cell_type": "markdown",
"id": "98881255-a906-4f4f-aeaa-788a46b9fcc1",
"metadata": {},
"source": [
"## Seasons"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "168c34f5-3035-410f-bc74-51c4af9ca4d7",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" | \n",
" league_id | \n",
" season_id | \n",
" url | \n",
"
\n",
" \n",
" | league | \n",
" season | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | ENG-Premier League | \n",
" 1516 | \n",
" 1 | \n",
" 2015 | \n",
" https://understat.com/league/EPL/2015 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" league_id season_id \\\n",
"league season \n",
"ENG-Premier League 1516 1 2015 \n",
"\n",
" url \n",
"league season \n",
"ENG-Premier League 1516 https://understat.com/league/EPL/2015 "
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"seasons = understat.read_seasons()\n",
"seasons.head()"
]
},
{
"cell_type": "markdown",
"id": "eb5fabf3",
"metadata": {},
"source": [
"## Schedule"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "66ce10da",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" | \n",
" | \n",
" league_id | \n",
" season_id | \n",
" game_id | \n",
" date | \n",
" home_team_id | \n",
" away_team_id | \n",
" home_team | \n",
" away_team | \n",
" away_team_code | \n",
" home_team_code | \n",
" home_goals | \n",
" away_goals | \n",
" home_xg | \n",
" away_xg | \n",
" is_result | \n",
" has_data | \n",
" url | \n",
"
\n",
" \n",
" | league | \n",
" season | \n",
" game | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | ENG-Premier League | \n",
" 1516 | \n",
" 2015-08-08 Bournemouth-Aston Villa | \n",
" 1 | \n",
" 2015 | \n",
" 82 | \n",
" 2015-08-08 18:00:00 | \n",
" 73 | \n",
" 71 | \n",
" Bournemouth | \n",
" Aston Villa | \n",
" AVL | \n",
" BOU | \n",
" 0 | \n",
" 1 | \n",
" 0.876106 | \n",
" 0.782253 | \n",
" True | \n",
" True | \n",
" https://understat.com/match/82 | \n",
"
\n",
" \n",
" | 2015-08-08 Chelsea-Swansea | \n",
" 1 | \n",
" 2015 | \n",
" 86 | \n",
" 2015-08-08 20:30:00 | \n",
" 80 | \n",
" 84 | \n",
" Chelsea | \n",
" Swansea | \n",
" SWA | \n",
" CHE | \n",
" 2 | \n",
" 2 | \n",
" 0.64396 | \n",
" 2.59203 | \n",
" True | \n",
" True | \n",
" https://understat.com/match/86 | \n",
"
\n",
" \n",
" | 2015-08-08 Everton-Watford | \n",
" 1 | \n",
" 2015 | \n",
" 83 | \n",
" 2015-08-08 18:00:00 | \n",
" 72 | \n",
" 90 | \n",
" Everton | \n",
" Watford | \n",
" WAT | \n",
" EVE | \n",
" 2 | \n",
" 2 | \n",
" 0.604226 | \n",
" 0.557892 | \n",
" True | \n",
" True | \n",
" https://understat.com/match/83 | \n",
"
\n",
" \n",
" | 2015-08-08 Leicester-Sunderland | \n",
" 1 | \n",
" 2015 | \n",
" 84 | \n",
" 2015-08-08 18:00:00 | \n",
" 75 | \n",
" 77 | \n",
" Leicester | \n",
" Sunderland | \n",
" SUN | \n",
" LEI | \n",
" 4 | \n",
" 2 | \n",
" 2.56803 | \n",
" 1.45946 | \n",
" True | \n",
" True | \n",
" https://understat.com/match/84 | \n",
"
\n",
" \n",
" | 2015-08-08 Manchester United-Tottenham | \n",
" 1 | \n",
" 2015 | \n",
" 81 | \n",
" 2015-08-08 15:45:00 | \n",
" 89 | \n",
" 82 | \n",
" Manchester United | \n",
" Tottenham | \n",
" TOT | \n",
" MUN | \n",
" 1 | \n",
" 0 | \n",
" 0.627539 | \n",
" 0.6746 | \n",
" True | \n",
" True | \n",
" https://understat.com/match/81 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" league_id \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 1 \n",
" 2015-08-08 Chelsea-Swansea 1 \n",
" 2015-08-08 Everton-Watford 1 \n",
" 2015-08-08 Leicester-Sunderland 1 \n",
" 2015-08-08 Manchester United-Tottenham 1 \n",
"\n",
" season_id \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 2015 \n",
" 2015-08-08 Chelsea-Swansea 2015 \n",
" 2015-08-08 Everton-Watford 2015 \n",
" 2015-08-08 Leicester-Sunderland 2015 \n",
" 2015-08-08 Manchester United-Tottenham 2015 \n",
"\n",
" game_id \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 82 \n",
" 2015-08-08 Chelsea-Swansea 86 \n",
" 2015-08-08 Everton-Watford 83 \n",
" 2015-08-08 Leicester-Sunderland 84 \n",
" 2015-08-08 Manchester United-Tottenham 81 \n",
"\n",
" date \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 2015-08-08 18:00:00 \n",
" 2015-08-08 Chelsea-Swansea 2015-08-08 20:30:00 \n",
" 2015-08-08 Everton-Watford 2015-08-08 18:00:00 \n",
" 2015-08-08 Leicester-Sunderland 2015-08-08 18:00:00 \n",
" 2015-08-08 Manchester United-Tottenham 2015-08-08 15:45:00 \n",
"\n",
" home_team_id \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 73 \n",
" 2015-08-08 Chelsea-Swansea 80 \n",
" 2015-08-08 Everton-Watford 72 \n",
" 2015-08-08 Leicester-Sunderland 75 \n",
" 2015-08-08 Manchester United-Tottenham 89 \n",
"\n",
" away_team_id \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 71 \n",
" 2015-08-08 Chelsea-Swansea 84 \n",
" 2015-08-08 Everton-Watford 90 \n",
" 2015-08-08 Leicester-Sunderland 77 \n",
" 2015-08-08 Manchester United-Tottenham 82 \n",
"\n",
" home_team \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Bournemouth \n",
" 2015-08-08 Chelsea-Swansea Chelsea \n",
" 2015-08-08 Everton-Watford Everton \n",
" 2015-08-08 Leicester-Sunderland Leicester \n",
" 2015-08-08 Manchester United-Tottenham Manchester United \n",
"\n",
" away_team \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa \n",
" 2015-08-08 Chelsea-Swansea Swansea \n",
" 2015-08-08 Everton-Watford Watford \n",
" 2015-08-08 Leicester-Sunderland Sunderland \n",
" 2015-08-08 Manchester United-Tottenham Tottenham \n",
"\n",
" away_team_code \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa AVL \n",
" 2015-08-08 Chelsea-Swansea SWA \n",
" 2015-08-08 Everton-Watford WAT \n",
" 2015-08-08 Leicester-Sunderland SUN \n",
" 2015-08-08 Manchester United-Tottenham TOT \n",
"\n",
" home_team_code \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa BOU \n",
" 2015-08-08 Chelsea-Swansea CHE \n",
" 2015-08-08 Everton-Watford EVE \n",
" 2015-08-08 Leicester-Sunderland LEI \n",
" 2015-08-08 Manchester United-Tottenham MUN \n",
"\n",
" home_goals \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 0 \n",
" 2015-08-08 Chelsea-Swansea 2 \n",
" 2015-08-08 Everton-Watford 2 \n",
" 2015-08-08 Leicester-Sunderland 4 \n",
" 2015-08-08 Manchester United-Tottenham 1 \n",
"\n",
" away_goals \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 1 \n",
" 2015-08-08 Chelsea-Swansea 2 \n",
" 2015-08-08 Everton-Watford 2 \n",
" 2015-08-08 Leicester-Sunderland 2 \n",
" 2015-08-08 Manchester United-Tottenham 0 \n",
"\n",
" home_xg \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 0.876106 \n",
" 2015-08-08 Chelsea-Swansea 0.64396 \n",
" 2015-08-08 Everton-Watford 0.604226 \n",
" 2015-08-08 Leicester-Sunderland 2.56803 \n",
" 2015-08-08 Manchester United-Tottenham 0.627539 \n",
"\n",
" away_xg \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 0.782253 \n",
" 2015-08-08 Chelsea-Swansea 2.59203 \n",
" 2015-08-08 Everton-Watford 0.557892 \n",
" 2015-08-08 Leicester-Sunderland 1.45946 \n",
" 2015-08-08 Manchester United-Tottenham 0.6746 \n",
"\n",
" is_result \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa True \n",
" 2015-08-08 Chelsea-Swansea True \n",
" 2015-08-08 Everton-Watford True \n",
" 2015-08-08 Leicester-Sunderland True \n",
" 2015-08-08 Manchester United-Tottenham True \n",
"\n",
" has_data \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa True \n",
" 2015-08-08 Chelsea-Swansea True \n",
" 2015-08-08 Everton-Watford True \n",
" 2015-08-08 Leicester-Sunderland True \n",
" 2015-08-08 Manchester United-Tottenham True \n",
"\n",
" url \n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa https://understat.com/match/82 \n",
" 2015-08-08 Chelsea-Swansea https://understat.com/match/86 \n",
" 2015-08-08 Everton-Watford https://understat.com/match/83 \n",
" 2015-08-08 Leicester-Sunderland https://understat.com/match/84 \n",
" 2015-08-08 Manchester United-Tottenham https://understat.com/match/81 "
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"schedule = understat.read_schedule()\n",
"schedule.head()"
]
},
{
"cell_type": "markdown",
"id": "7bd05a01",
"metadata": {},
"source": [
"## Team match stats"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "bc789ef7",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" | \n",
" | \n",
" league_id | \n",
" season_id | \n",
" game_id | \n",
" date | \n",
" home_team_id | \n",
" away_team_id | \n",
" home_team | \n",
" away_team | \n",
" away_team_code | \n",
" home_team_code | \n",
" ... | \n",
" away_ppda | \n",
" away_deep_completions | \n",
" home_points | \n",
" home_expected_points | \n",
" home_goals | \n",
" home_xg | \n",
" home_np_xg | \n",
" home_np_xg_difference | \n",
" home_ppda | \n",
" home_deep_completions | \n",
"
\n",
" \n",
" | league | \n",
" season | \n",
" game | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | ENG-Premier League | \n",
" 1516 | \n",
" 2015-08-08 Bournemouth-Aston Villa | \n",
" 1 | \n",
" 2015 | \n",
" 82 | \n",
" 2015-08-08 18:00:00 | \n",
" 73 | \n",
" 71 | \n",
" Bournemouth | \n",
" Aston Villa | \n",
" AVL | \n",
" BOU | \n",
" ... | \n",
" 11.846154 | \n",
" 2 | \n",
" 0 | \n",
" 1.3912 | \n",
" 0 | \n",
" 0.876106 | \n",
" 0.876106 | \n",
" 0.093853 | \n",
" 6.9 | \n",
" 11 | \n",
"
\n",
" \n",
" | 2015-08-08 Chelsea-Swansea | \n",
" 1 | \n",
" 2015 | \n",
" 86 | \n",
" 2015-08-08 20:30:00 | \n",
" 80 | \n",
" 84 | \n",
" Chelsea | \n",
" Swansea | \n",
" SWA | \n",
" CHE | \n",
" ... | \n",
" 8.833333 | \n",
" 5 | \n",
" 1 | \n",
" 0.1836 | \n",
" 2 | \n",
" 0.64396 | \n",
" 0.64396 | \n",
" -1.1869 | \n",
" 10.363636 | \n",
" 10 | \n",
"
\n",
" \n",
" | 2015-08-08 Everton-Watford | \n",
" 1 | \n",
" 2015 | \n",
" 83 | \n",
" 2015-08-08 18:00:00 | \n",
" 72 | \n",
" 90 | \n",
" Everton | \n",
" Watford | \n",
" WAT | \n",
" EVE | \n",
" ... | \n",
" 17.157895 | \n",
" 4 | \n",
" 1 | \n",
" 1.3301 | \n",
" 2 | \n",
" 0.604226 | \n",
" 0.604226 | \n",
" 0.046334 | \n",
" 6.65 | \n",
" 5 | \n",
"
\n",
" \n",
" | 2015-08-08 Leicester-Sunderland | \n",
" 1 | \n",
" 2015 | \n",
" 84 | \n",
" 2015-08-08 18:00:00 | \n",
" 75 | \n",
" 77 | \n",
" Leicester | \n",
" Sunderland | \n",
" SUN | \n",
" LEI | \n",
" ... | \n",
" 9.555556 | \n",
" 6 | \n",
" 3 | \n",
" 2.1323 | \n",
" 4 | \n",
" 2.56803 | \n",
" 1.80686 | \n",
" 0.3474 | \n",
" 10.88 | \n",
" 5 | \n",
"
\n",
" \n",
" | 2015-08-08 Manchester United-Tottenham | \n",
" 1 | \n",
" 2015 | \n",
" 81 | \n",
" 2015-08-08 15:45:00 | \n",
" 89 | \n",
" 82 | \n",
" Manchester United | \n",
" Tottenham | \n",
" TOT | \n",
" MUN | \n",
" ... | \n",
" 8.21875 | \n",
" 10 | \n",
" 3 | \n",
" 1.2482 | \n",
" 1 | \n",
" 0.627539 | \n",
" 0.627539 | \n",
" -0.047061 | \n",
" 13.826087 | \n",
" 4 | \n",
"
\n",
" \n",
"
\n",
"
5 rows × 26 columns
\n",
"
"
],
"text/plain": [
" league_id \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 1 \n",
" 2015-08-08 Chelsea-Swansea 1 \n",
" 2015-08-08 Everton-Watford 1 \n",
" 2015-08-08 Leicester-Sunderland 1 \n",
" 2015-08-08 Manchester United-Tottenham 1 \n",
"\n",
" season_id \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 2015 \n",
" 2015-08-08 Chelsea-Swansea 2015 \n",
" 2015-08-08 Everton-Watford 2015 \n",
" 2015-08-08 Leicester-Sunderland 2015 \n",
" 2015-08-08 Manchester United-Tottenham 2015 \n",
"\n",
" game_id \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 82 \n",
" 2015-08-08 Chelsea-Swansea 86 \n",
" 2015-08-08 Everton-Watford 83 \n",
" 2015-08-08 Leicester-Sunderland 84 \n",
" 2015-08-08 Manchester United-Tottenham 81 \n",
"\n",
" date \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 2015-08-08 18:00:00 \n",
" 2015-08-08 Chelsea-Swansea 2015-08-08 20:30:00 \n",
" 2015-08-08 Everton-Watford 2015-08-08 18:00:00 \n",
" 2015-08-08 Leicester-Sunderland 2015-08-08 18:00:00 \n",
" 2015-08-08 Manchester United-Tottenham 2015-08-08 15:45:00 \n",
"\n",
" home_team_id \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 73 \n",
" 2015-08-08 Chelsea-Swansea 80 \n",
" 2015-08-08 Everton-Watford 72 \n",
" 2015-08-08 Leicester-Sunderland 75 \n",
" 2015-08-08 Manchester United-Tottenham 89 \n",
"\n",
" away_team_id \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 71 \n",
" 2015-08-08 Chelsea-Swansea 84 \n",
" 2015-08-08 Everton-Watford 90 \n",
" 2015-08-08 Leicester-Sunderland 77 \n",
" 2015-08-08 Manchester United-Tottenham 82 \n",
"\n",
" home_team \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Bournemouth \n",
" 2015-08-08 Chelsea-Swansea Chelsea \n",
" 2015-08-08 Everton-Watford Everton \n",
" 2015-08-08 Leicester-Sunderland Leicester \n",
" 2015-08-08 Manchester United-Tottenham Manchester United \n",
"\n",
" away_team \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa \n",
" 2015-08-08 Chelsea-Swansea Swansea \n",
" 2015-08-08 Everton-Watford Watford \n",
" 2015-08-08 Leicester-Sunderland Sunderland \n",
" 2015-08-08 Manchester United-Tottenham Tottenham \n",
"\n",
" away_team_code \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa AVL \n",
" 2015-08-08 Chelsea-Swansea SWA \n",
" 2015-08-08 Everton-Watford WAT \n",
" 2015-08-08 Leicester-Sunderland SUN \n",
" 2015-08-08 Manchester United-Tottenham TOT \n",
"\n",
" home_team_code \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa BOU \n",
" 2015-08-08 Chelsea-Swansea CHE \n",
" 2015-08-08 Everton-Watford EVE \n",
" 2015-08-08 Leicester-Sunderland LEI \n",
" 2015-08-08 Manchester United-Tottenham MUN \n",
"\n",
" ... \\\n",
"league season game ... \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa ... \n",
" 2015-08-08 Chelsea-Swansea ... \n",
" 2015-08-08 Everton-Watford ... \n",
" 2015-08-08 Leicester-Sunderland ... \n",
" 2015-08-08 Manchester United-Tottenham ... \n",
"\n",
" away_ppda \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 11.846154 \n",
" 2015-08-08 Chelsea-Swansea 8.833333 \n",
" 2015-08-08 Everton-Watford 17.157895 \n",
" 2015-08-08 Leicester-Sunderland 9.555556 \n",
" 2015-08-08 Manchester United-Tottenham 8.21875 \n",
"\n",
" away_deep_completions \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 2 \n",
" 2015-08-08 Chelsea-Swansea 5 \n",
" 2015-08-08 Everton-Watford 4 \n",
" 2015-08-08 Leicester-Sunderland 6 \n",
" 2015-08-08 Manchester United-Tottenham 10 \n",
"\n",
" home_points \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 0 \n",
" 2015-08-08 Chelsea-Swansea 1 \n",
" 2015-08-08 Everton-Watford 1 \n",
" 2015-08-08 Leicester-Sunderland 3 \n",
" 2015-08-08 Manchester United-Tottenham 3 \n",
"\n",
" home_expected_points \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 1.3912 \n",
" 2015-08-08 Chelsea-Swansea 0.1836 \n",
" 2015-08-08 Everton-Watford 1.3301 \n",
" 2015-08-08 Leicester-Sunderland 2.1323 \n",
" 2015-08-08 Manchester United-Tottenham 1.2482 \n",
"\n",
" home_goals \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 0 \n",
" 2015-08-08 Chelsea-Swansea 2 \n",
" 2015-08-08 Everton-Watford 2 \n",
" 2015-08-08 Leicester-Sunderland 4 \n",
" 2015-08-08 Manchester United-Tottenham 1 \n",
"\n",
" home_xg \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 0.876106 \n",
" 2015-08-08 Chelsea-Swansea 0.64396 \n",
" 2015-08-08 Everton-Watford 0.604226 \n",
" 2015-08-08 Leicester-Sunderland 2.56803 \n",
" 2015-08-08 Manchester United-Tottenham 0.627539 \n",
"\n",
" home_np_xg \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 0.876106 \n",
" 2015-08-08 Chelsea-Swansea 0.64396 \n",
" 2015-08-08 Everton-Watford 0.604226 \n",
" 2015-08-08 Leicester-Sunderland 1.80686 \n",
" 2015-08-08 Manchester United-Tottenham 0.627539 \n",
"\n",
" home_np_xg_difference \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 0.093853 \n",
" 2015-08-08 Chelsea-Swansea -1.1869 \n",
" 2015-08-08 Everton-Watford 0.046334 \n",
" 2015-08-08 Leicester-Sunderland 0.3474 \n",
" 2015-08-08 Manchester United-Tottenham -0.047061 \n",
"\n",
" home_ppda \\\n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 6.9 \n",
" 2015-08-08 Chelsea-Swansea 10.363636 \n",
" 2015-08-08 Everton-Watford 6.65 \n",
" 2015-08-08 Leicester-Sunderland 10.88 \n",
" 2015-08-08 Manchester United-Tottenham 13.826087 \n",
"\n",
" home_deep_completions \n",
"league season game \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa 11 \n",
" 2015-08-08 Chelsea-Swansea 10 \n",
" 2015-08-08 Everton-Watford 5 \n",
" 2015-08-08 Leicester-Sunderland 5 \n",
" 2015-08-08 Manchester United-Tottenham 4 \n",
"\n",
"[5 rows x 26 columns]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"team_match_stats = understat.read_team_match_stats()\n",
"team_match_stats.head()"
]
},
{
"cell_type": "markdown",
"id": "7c07e843",
"metadata": {},
"source": [
"## Player season stats"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "4b9cb8d8",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" | \n",
" | \n",
" league_id | \n",
" season_id | \n",
" team | \n",
" team_id | \n",
" player_id | \n",
" position | \n",
" matches | \n",
" minutes | \n",
" goals | \n",
" xg | \n",
" np_goals | \n",
" np_xg | \n",
" assists | \n",
" xa | \n",
" shots | \n",
" key_passes | \n",
" yellow_cards | \n",
" red_cards | \n",
" xg_chain | \n",
" xg_buildup | \n",
"
\n",
" \n",
" | league | \n",
" season | \n",
" player | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | ENG-Premier League | \n",
" 1516 | \n",
" Aaron Cresswell | \n",
" 1 | \n",
" 2015 | \n",
" West Ham | \n",
" 81 | \n",
" 534 | \n",
" D M | \n",
" 37 | \n",
" 3319 | \n",
" 2 | \n",
" 1.092563 | \n",
" 2 | \n",
" 1.092563 | \n",
" 4 | \n",
" 3.294618 | \n",
" 28 | \n",
" 40 | \n",
" 1 | \n",
" 0 | \n",
" 10.339367 | \n",
" 6.831139 | \n",
"
\n",
" \n",
" | Aaron Lennon | \n",
" 1 | \n",
" 2015 | \n",
" Everton | \n",
" 72 | \n",
" 593 | \n",
" F M S | \n",
" 25 | \n",
" 1534 | \n",
" 5 | \n",
" 2.226095 | \n",
" 5 | \n",
" 2.226095 | \n",
" 0 | \n",
" 1.697951 | \n",
" 18 | \n",
" 23 | \n",
" 1 | \n",
" 0 | \n",
" 5.535392 | \n",
" 1.90374 | \n",
"
\n",
" \n",
" | Aaron Ramsey | \n",
" 1 | \n",
" 2015 | \n",
" Arsenal | \n",
" 83 | \n",
" 504 | \n",
" M S | \n",
" 31 | \n",
" 2624 | \n",
" 5 | \n",
" 8.614323 | \n",
" 5 | \n",
" 8.614323 | \n",
" 4 | \n",
" 4.046242 | \n",
" 69 | \n",
" 37 | \n",
" 4 | \n",
" 0 | \n",
" 23.282566 | \n",
" 14.176444 | \n",
"
\n",
" \n",
" | Abdul Rahman Baba | \n",
" 1 | \n",
" 2015 | \n",
" Chelsea | \n",
" 80 | \n",
" 684 | \n",
" D S | \n",
" 15 | \n",
" 1018 | \n",
" 0 | \n",
" 0.379115 | \n",
" 0 | \n",
" 0.379115 | \n",
" 1 | \n",
" 0.179241 | \n",
" 6 | \n",
" 3 | \n",
" 1 | \n",
" 0 | \n",
" 3.869669 | \n",
" 3.490554 | \n",
"
\n",
" \n",
" | Adam Bogdan | \n",
" 1 | \n",
" 2015 | \n",
" Liverpool | \n",
" 87 | \n",
" 698 | \n",
" GK | \n",
" 2 | \n",
" 180 | \n",
" 0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0.120216 | \n",
" 0.120216 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" league_id season_id team \\\n",
"league season player \n",
"ENG-Premier League 1516 Aaron Cresswell 1 2015 West Ham \n",
" Aaron Lennon 1 2015 Everton \n",
" Aaron Ramsey 1 2015 Arsenal \n",
" Abdul Rahman Baba 1 2015 Chelsea \n",
" Adam Bogdan 1 2015 Liverpool \n",
"\n",
" team_id player_id position \\\n",
"league season player \n",
"ENG-Premier League 1516 Aaron Cresswell 81 534 D M \n",
" Aaron Lennon 72 593 F M S \n",
" Aaron Ramsey 83 504 M S \n",
" Abdul Rahman Baba 80 684 D S \n",
" Adam Bogdan 87 698 GK \n",
"\n",
" matches minutes goals \\\n",
"league season player \n",
"ENG-Premier League 1516 Aaron Cresswell 37 3319 2 \n",
" Aaron Lennon 25 1534 5 \n",
" Aaron Ramsey 31 2624 5 \n",
" Abdul Rahman Baba 15 1018 0 \n",
" Adam Bogdan 2 180 0 \n",
"\n",
" xg np_goals np_xg \\\n",
"league season player \n",
"ENG-Premier League 1516 Aaron Cresswell 1.092563 2 1.092563 \n",
" Aaron Lennon 2.226095 5 2.226095 \n",
" Aaron Ramsey 8.614323 5 8.614323 \n",
" Abdul Rahman Baba 0.379115 0 0.379115 \n",
" Adam Bogdan 0.0 0 0.0 \n",
"\n",
" assists xa shots \\\n",
"league season player \n",
"ENG-Premier League 1516 Aaron Cresswell 4 3.294618 28 \n",
" Aaron Lennon 0 1.697951 18 \n",
" Aaron Ramsey 4 4.046242 69 \n",
" Abdul Rahman Baba 1 0.179241 6 \n",
" Adam Bogdan 0 0.0 0 \n",
"\n",
" key_passes yellow_cards \\\n",
"league season player \n",
"ENG-Premier League 1516 Aaron Cresswell 40 1 \n",
" Aaron Lennon 23 1 \n",
" Aaron Ramsey 37 4 \n",
" Abdul Rahman Baba 3 1 \n",
" Adam Bogdan 0 0 \n",
"\n",
" red_cards xg_chain xg_buildup \n",
"league season player \n",
"ENG-Premier League 1516 Aaron Cresswell 0 10.339367 6.831139 \n",
" Aaron Lennon 0 5.535392 1.90374 \n",
" Aaron Ramsey 0 23.282566 14.176444 \n",
" Abdul Rahman Baba 0 3.869669 3.490554 \n",
" Adam Bogdan 0 0.120216 0.120216 "
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"player_season_stats = understat.read_player_season_stats()\n",
"player_season_stats.head()"
]
},
{
"cell_type": "markdown",
"id": "04162974",
"metadata": {},
"source": [
"## Player match stats"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "5ef60999",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" league_id | \n",
" season_id | \n",
" game_id | \n",
" team_id | \n",
" player_id | \n",
" position | \n",
" position_id | \n",
" minutes | \n",
" goals | \n",
" own_goals | \n",
" shots | \n",
" xg | \n",
" xa | \n",
" xg_chain | \n",
" xg_buildup | \n",
"
\n",
" \n",
" | league | \n",
" season | \n",
" game | \n",
" team | \n",
" player | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | ENG-Premier League | \n",
" 1516 | \n",
" 2015-08-08 Bournemouth-Aston Villa | \n",
" Aston Villa | \n",
" Ashley Westwood | \n",
" 1 | \n",
" 2015 | \n",
" 82 | \n",
" 71 | \n",
" 669 | \n",
" MC | \n",
" 9 | \n",
" 90 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0.374082 | \n",
" 0.131937 | \n",
" 0.131937 | \n",
"
\n",
" \n",
" | Brad Guzan | \n",
" 1 | \n",
" 2015 | \n",
" 82 | \n",
" 71 | \n",
" 662 | \n",
" GK | \n",
" 1 | \n",
" 90 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | Carlos Sánchez | \n",
" 1 | \n",
" 2015 | \n",
" 82 | \n",
" 71 | \n",
" 667 | \n",
" Sub | \n",
" 17 | \n",
" 18 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | Ciaran Clark | \n",
" 1 | \n",
" 2015 | \n",
" 82 | \n",
" 71 | \n",
" 875 | \n",
" DC | \n",
" 3 | \n",
" 90 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.131937 | \n",
" 0.131937 | \n",
"
\n",
" \n",
" | Gabriel Agbonlahor | \n",
" 1 | \n",
" 2015 | \n",
" 82 | \n",
" 71 | \n",
" 890 | \n",
" FW | \n",
" 15 | \n",
" 90 | \n",
" 0 | \n",
" 0 | \n",
" 2 | \n",
" 0.13016 | \n",
" 0.113668 | \n",
" 0.243828 | \n",
" 0.0 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" league_id \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Ashley Westwood 1 \n",
" Brad Guzan 1 \n",
" Carlos Sánchez 1 \n",
" Ciaran Clark 1 \n",
" Gabriel Agbonlahor 1 \n",
"\n",
" season_id \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Ashley Westwood 2015 \n",
" Brad Guzan 2015 \n",
" Carlos Sánchez 2015 \n",
" Ciaran Clark 2015 \n",
" Gabriel Agbonlahor 2015 \n",
"\n",
" game_id \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Ashley Westwood 82 \n",
" Brad Guzan 82 \n",
" Carlos Sánchez 82 \n",
" Ciaran Clark 82 \n",
" Gabriel Agbonlahor 82 \n",
"\n",
" team_id \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Ashley Westwood 71 \n",
" Brad Guzan 71 \n",
" Carlos Sánchez 71 \n",
" Ciaran Clark 71 \n",
" Gabriel Agbonlahor 71 \n",
"\n",
" player_id \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Ashley Westwood 669 \n",
" Brad Guzan 662 \n",
" Carlos Sánchez 667 \n",
" Ciaran Clark 875 \n",
" Gabriel Agbonlahor 890 \n",
"\n",
" position \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Ashley Westwood MC \n",
" Brad Guzan GK \n",
" Carlos Sánchez Sub \n",
" Ciaran Clark DC \n",
" Gabriel Agbonlahor FW \n",
"\n",
" position_id \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Ashley Westwood 9 \n",
" Brad Guzan 1 \n",
" Carlos Sánchez 17 \n",
" Ciaran Clark 3 \n",
" Gabriel Agbonlahor 15 \n",
"\n",
" minutes \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Ashley Westwood 90 \n",
" Brad Guzan 90 \n",
" Carlos Sánchez 18 \n",
" Ciaran Clark 90 \n",
" Gabriel Agbonlahor 90 \n",
"\n",
" goals \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Ashley Westwood 0 \n",
" Brad Guzan 0 \n",
" Carlos Sánchez 0 \n",
" Ciaran Clark 0 \n",
" Gabriel Agbonlahor 0 \n",
"\n",
" own_goals \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Ashley Westwood 0 \n",
" Brad Guzan 0 \n",
" Carlos Sánchez 0 \n",
" Ciaran Clark 0 \n",
" Gabriel Agbonlahor 0 \n",
"\n",
" shots \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Ashley Westwood 0 \n",
" Brad Guzan 0 \n",
" Carlos Sánchez 0 \n",
" Ciaran Clark 0 \n",
" Gabriel Agbonlahor 2 \n",
"\n",
" xg \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Ashley Westwood 0.0 \n",
" Brad Guzan 0.0 \n",
" Carlos Sánchez 0.0 \n",
" Ciaran Clark 0.0 \n",
" Gabriel Agbonlahor 0.13016 \n",
"\n",
" xa \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Ashley Westwood 0.374082 \n",
" Brad Guzan 0.0 \n",
" Carlos Sánchez 0.0 \n",
" Ciaran Clark 0.0 \n",
" Gabriel Agbonlahor 0.113668 \n",
"\n",
" xg_chain \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Ashley Westwood 0.131937 \n",
" Brad Guzan 0.0 \n",
" Carlos Sánchez 0.0 \n",
" Ciaran Clark 0.131937 \n",
" Gabriel Agbonlahor 0.243828 \n",
"\n",
" xg_buildup \n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Ashley Westwood 0.131937 \n",
" Brad Guzan 0.0 \n",
" Carlos Sánchez 0.0 \n",
" Ciaran Clark 0.131937 \n",
" Gabriel Agbonlahor 0.0 "
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"player_match_stats = understat.read_player_match_stats()\n",
"player_match_stats.head()"
]
},
{
"cell_type": "markdown",
"id": "6da5002a",
"metadata": {},
"source": [
"## Shot events"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "aad9366c",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" league_id | \n",
" season_id | \n",
" game_id | \n",
" date | \n",
" shot_id | \n",
" team_id | \n",
" player_id | \n",
" assist_player_id | \n",
" assist_player | \n",
" xg | \n",
" location_x | \n",
" location_y | \n",
" minute | \n",
" body_part | \n",
" situation | \n",
" result | \n",
"
\n",
" \n",
" | league | \n",
" season | \n",
" game | \n",
" team | \n",
" player | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | ENG-Premier League | \n",
" 1516 | \n",
" 2015-08-08 Bournemouth-Aston Villa | \n",
" Aston Villa | \n",
" Gabriel Agbonlahor | \n",
" 1 | \n",
" 2015 | \n",
" 82 | \n",
" 2015-08-08 18:00:00 | \n",
" 487146 | \n",
" 71 | \n",
" 890 | \n",
" <NA> | \n",
" <NA> | \n",
" 0.075484 | \n",
" 0.86 | \n",
" 0.503 | \n",
" 67 | \n",
" Left Foot | \n",
" Open Play | \n",
" Blocked Shot | \n",
"
\n",
" \n",
" | Gabriel Agbonlahor | \n",
" 1 | \n",
" 2015 | \n",
" 82 | \n",
" 2015-08-08 18:00:00 | \n",
" 487150 | \n",
" 71 | \n",
" 890 | \n",
" 548651 | \n",
" Micah Richards | \n",
" 0.054676 | \n",
" 0.795 | \n",
" 0.507 | \n",
" 81 | \n",
" Left Foot | \n",
" Open Play | \n",
" Saved Shot | \n",
"
\n",
" \n",
" | Idrissa Gueye | \n",
" 1 | \n",
" 2015 | \n",
" 82 | \n",
" 2015-08-08 18:00:00 | \n",
" 487136 | \n",
" 71 | \n",
" 668 | \n",
" 548653 | \n",
" Jordan Veretout | \n",
" 0.018269 | \n",
" 0.742 | \n",
" 0.598 | \n",
" 26 | \n",
" Right Foot | \n",
" Open Play | \n",
" Missed Shot | \n",
"
\n",
" \n",
" | Idrissa Gueye | \n",
" 1 | \n",
" 2015 | \n",
" 82 | \n",
" 2015-08-08 18:00:00 | \n",
" 487144 | \n",
" 71 | \n",
" 668 | \n",
" 548657 | \n",
" Gabriel Agbonlahor | \n",
" 0.113668 | \n",
" 0.883 | \n",
" 0.561 | \n",
" 47 | \n",
" Left Foot | \n",
" Open Play | \n",
" Saved Shot | \n",
"
\n",
" \n",
" | Leandro Bacuna | \n",
" 1 | \n",
" 2015 | \n",
" 82 | \n",
" 2015-08-08 18:00:00 | \n",
" 487141 | \n",
" 71 | \n",
" 674 | \n",
" <NA> | \n",
" <NA> | \n",
" 0.097371 | \n",
" 0.786 | \n",
" 0.437 | \n",
" 42 | \n",
" Right Foot | \n",
" Direct Freekick | \n",
" Blocked Shot | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" league_id \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Gabriel Agbonlahor 1 \n",
" Gabriel Agbonlahor 1 \n",
" Idrissa Gueye 1 \n",
" Idrissa Gueye 1 \n",
" Leandro Bacuna 1 \n",
"\n",
" season_id \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Gabriel Agbonlahor 2015 \n",
" Gabriel Agbonlahor 2015 \n",
" Idrissa Gueye 2015 \n",
" Idrissa Gueye 2015 \n",
" Leandro Bacuna 2015 \n",
"\n",
" game_id \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Gabriel Agbonlahor 82 \n",
" Gabriel Agbonlahor 82 \n",
" Idrissa Gueye 82 \n",
" Idrissa Gueye 82 \n",
" Leandro Bacuna 82 \n",
"\n",
" date \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Gabriel Agbonlahor 2015-08-08 18:00:00 \n",
" Gabriel Agbonlahor 2015-08-08 18:00:00 \n",
" Idrissa Gueye 2015-08-08 18:00:00 \n",
" Idrissa Gueye 2015-08-08 18:00:00 \n",
" Leandro Bacuna 2015-08-08 18:00:00 \n",
"\n",
" shot_id \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Gabriel Agbonlahor 487146 \n",
" Gabriel Agbonlahor 487150 \n",
" Idrissa Gueye 487136 \n",
" Idrissa Gueye 487144 \n",
" Leandro Bacuna 487141 \n",
"\n",
" team_id \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Gabriel Agbonlahor 71 \n",
" Gabriel Agbonlahor 71 \n",
" Idrissa Gueye 71 \n",
" Idrissa Gueye 71 \n",
" Leandro Bacuna 71 \n",
"\n",
" player_id \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Gabriel Agbonlahor 890 \n",
" Gabriel Agbonlahor 890 \n",
" Idrissa Gueye 668 \n",
" Idrissa Gueye 668 \n",
" Leandro Bacuna 674 \n",
"\n",
" assist_player_id \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Gabriel Agbonlahor \n",
" Gabriel Agbonlahor 548651 \n",
" Idrissa Gueye 548653 \n",
" Idrissa Gueye 548657 \n",
" Leandro Bacuna \n",
"\n",
" assist_player \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Gabriel Agbonlahor \n",
" Gabriel Agbonlahor Micah Richards \n",
" Idrissa Gueye Jordan Veretout \n",
" Idrissa Gueye Gabriel Agbonlahor \n",
" Leandro Bacuna \n",
"\n",
" xg \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Gabriel Agbonlahor 0.075484 \n",
" Gabriel Agbonlahor 0.054676 \n",
" Idrissa Gueye 0.018269 \n",
" Idrissa Gueye 0.113668 \n",
" Leandro Bacuna 0.097371 \n",
"\n",
" location_x \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Gabriel Agbonlahor 0.86 \n",
" Gabriel Agbonlahor 0.795 \n",
" Idrissa Gueye 0.742 \n",
" Idrissa Gueye 0.883 \n",
" Leandro Bacuna 0.786 \n",
"\n",
" location_y \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Gabriel Agbonlahor 0.503 \n",
" Gabriel Agbonlahor 0.507 \n",
" Idrissa Gueye 0.598 \n",
" Idrissa Gueye 0.561 \n",
" Leandro Bacuna 0.437 \n",
"\n",
" minute \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Gabriel Agbonlahor 67 \n",
" Gabriel Agbonlahor 81 \n",
" Idrissa Gueye 26 \n",
" Idrissa Gueye 47 \n",
" Leandro Bacuna 42 \n",
"\n",
" body_part \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Gabriel Agbonlahor Left Foot \n",
" Gabriel Agbonlahor Left Foot \n",
" Idrissa Gueye Right Foot \n",
" Idrissa Gueye Left Foot \n",
" Leandro Bacuna Right Foot \n",
"\n",
" situation \\\n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Gabriel Agbonlahor Open Play \n",
" Gabriel Agbonlahor Open Play \n",
" Idrissa Gueye Open Play \n",
" Idrissa Gueye Open Play \n",
" Leandro Bacuna Direct Freekick \n",
"\n",
" result \n",
"league season game team player \n",
"ENG-Premier League 1516 2015-08-08 Bournemouth-Aston Villa Aston Villa Gabriel Agbonlahor Blocked Shot \n",
" Gabriel Agbonlahor Saved Shot \n",
" Idrissa Gueye Missed Shot \n",
" Idrissa Gueye Saved Shot \n",
" Leandro Bacuna Blocked Shot "
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"shot_events = understat.read_shot_events()\n",
"shot_events.head()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "soccerdata",
"language": "python",
"name": "soccerdata"
},
"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.12.1"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": true
}
},
"nbformat": 4,
"nbformat_minor": 5
}