{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "#Much of the scraping code is taken from this repository: https://github.com/chmartin/FBref_EPL\n", "#I've made the the necessary changes for the recently added data and for combining it" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "#standard(stats)\n", "stats = [\"player\",\"nationality\",\"position\",\"squad\",\"age\",\"birth_year\",\"games\",\"games_starts\",\"minutes\",\"goals\",\"assists\",\"pens_made\",\"pens_att\",\"cards_yellow\",\"cards_red\",\"goals_per90\",\"assists_per90\",\"goals_assists_per90\",\"goals_pens_per90\",\"goals_assists_pens_per90\",\"xg\",\"npxg\",\"xa\",\"xg_per90\",\"xa_per90\",\"xg_xa_per90\",\"npxg_per90\",\"npxg_xa_per90\"]\n", "stats3 = [\"players_used\",\"possession\",\"games\",\"games_starts\",\"minutes\",\"goals\",\"assists\",\"pens_made\",\"pens_att\",\"cards_yellow\",\"cards_red\",\"goals_per90\",\"assists_per90\",\"goals_assists_per90\",\"goals_pens_per90\",\"goals_assists_pens_per90\",\"xg\",\"npxg\",\"xa\",\"xg_per90\",\"xa_per90\",\"xg_xa_per90\",\"npxg_per90\",\"npxg_xa_per90\"] \n", "#goalkeeping(keepers)\n", "keepers = [\"player\",\"nationality\",\"position\",\"squad\",\"age\",\"birth_year\",\"games_gk\",\"games_starts_gk\",\"minutes_gk\",\"goals_against_gk\",\"goals_against_per90_gk\",\"shots_on_target_against\",\"saves\",\"save_pct\",\"wins_gk\",\"draws_gk\",\"losses_gk\",\"clean_sheets\",\"clean_sheets_pct\",\"pens_att_gk\",\"pens_allowed\",\"pens_saved\",\"pens_missed_gk\"]\n", "keepers3 = [\"players_used\",\"games_gk\",\"games_starts_gk\",\"minutes_gk\",\"goals_against_gk\",\"goals_against_per90_gk\",\"shots_on_target_against\",\"saves\",\"save_pct\",\"wins_gk\",\"draws_gk\",\"losses_gk\",\"clean_sheets\",\"clean_sheets_pct\",\"pens_att_gk\",\"pens_allowed\",\"pens_saved\",\"pens_missed_gk\"]\n", "#advance goalkeeping(keepersadv)\n", "keepersadv = [\"player\",\"nationality\",\"position\",\"squad\",\"age\",\"birth_year\",\"minutes_90s_gk\",\"goals_against_gk\",\"pens_allowed\",\"free_kick_goals_against_gk\",\"corner_kick_goals_against_gk\",\"own_goals_against_gk\",\"psxg_gk\",\"psnpxg_per_shot_on_target_against\",\"psxg_net_gk\",\"psxg_net_per90_gk\",\"passes_completed_launched_gk\",\"passes_launched_gk\",\"passes_pct_launched_gk\",\"passes_gk\",\"passes_throws_gk\",\"pct_passes_launched_gk\",\"passes_length_avg_gk\",\"goal_kicks\",\"pct_goal_kicks_launched\",\"goal_kick_length_avg\",\"crosses_gk\",\"crosses_stopped_gk\",\"crosses_stopped_pct_gk\",\"def_actions_outside_pen_area_gk\",\"def_actions_outside_pen_area_per90_gk\",\"avg_distance_def_actions_gk\"]\n", "keepersadv2 = [\"minutes_90s_gk\",\"goals_against_gk\",\"pens_allowed\",\"free_kick_goals_against_gk\",\"corner_kick_goals_against_gk\",\"own_goals_against_gk\",\"psxg_gk\",\"psnpxg_per_shot_on_target_against\",\"psxg_net_gk\",\"psxg_net_per90_gk\",\"passes_completed_launched_gk\",\"passes_launched_gk\",\"passes_pct_launched_gk\",\"passes_gk\",\"passes_throws_gk\",\"pct_passes_launched_gk\",\"passes_length_avg_gk\",\"goal_kicks\",\"pct_goal_kicks_launched\",\"goal_kick_length_avg\",\"crosses_gk\",\"crosses_stopped_gk\",\"crosses_stopped_pct_gk\",\"def_actions_outside_pen_area_gk\",\"def_actions_outside_pen_area_per90_gk\",\"avg_distance_def_actions_gk\"]\n", "#shooting(shooting)\n", "shooting = [\"player\",\"nationality\",\"position\",\"squad\",\"age\",\"birth_year\",\"minutes_90s\",\"goals\",\"pens_made\",\"pens_att\",\"shots_total\",\"shots_on_target\",\"shots_free_kicks\",\"shots_on_target_pct\",\"shots_total_per90\",\"shots_on_target_per90\",\"goals_per_shot\",\"goals_per_shot_on_target\",\"xg\",\"npxg\",\"npxg_per_shot\",\"xg_net\",\"npxg_net\"]\n", "shooting2 = [\"minutes_90s\",\"goals\",\"pens_made\",\"pens_att\",\"shots_total\",\"shots_on_target\",\"shots_free_kicks\",\"shots_on_target_pct\",\"shots_total_per90\",\"shots_on_target_per90\",\"goals_per_shot\",\"goals_per_shot_on_target\",\"xg\",\"npxg\",\"npxg_per_shot\",\"xg_net\",\"npxg_net\"]\n", "shooting3 = [\"goals\",\"pens_made\",\"pens_att\",\"shots_total\",\"shots_on_target\",\"shots_free_kicks\",\"shots_on_target_pct\",\"shots_total_per90\",\"shots_on_target_per90\",\"goals_per_shot\",\"goals_per_shot_on_target\",\"xg\",\"npxg\",\"npxg_per_shot\",\"xg_net\",\"npxg_net\"]\n", "#passing(passing)\n", "passing = [\"player\",\"nationality\",\"position\",\"squad\",\"age\",\"birth_year\",\"minutes_90s\",\"passes_completed\",\"passes\",\"passes_pct\",\"passes_total_distance\",\"passes_progressive_distance\",\"passes_completed_short\",\"passes_short\",\"passes_pct_short\",\"passes_completed_medium\",\"passes_medium\",\"passes_pct_medium\",\"passes_completed_long\",\"passes_long\",\"passes_pct_long\",\"assists\",\"xa\",\"xa_net\",\"assisted_shots\",\"passes_into_final_third\",\"passes_into_penalty_area\",\"crosses_into_penalty_area\",\"progressive_passes\"]\n", "passing2 = [\"passes_completed\",\"passes\",\"passes_pct\",\"passes_total_distance\",\"passes_progressive_distance\",\"passes_completed_short\",\"passes_short\",\"passes_pct_short\",\"passes_completed_medium\",\"passes_medium\",\"passes_pct_medium\",\"passes_completed_long\",\"passes_long\",\"passes_pct_long\",\"assists\",\"xa\",\"xa_net\",\"assisted_shots\",\"passes_into_final_third\",\"passes_into_penalty_area\",\"crosses_into_penalty_area\",\"progressive_passes\"]\n", "#passtypes(passing_types)\n", "passing_types = [\"player\",\"nationality\",\"position\",\"squad\",\"age\",\"birth_year\",\"minutes_90s\",\"passes\",\"passes_live\",\"passes_dead\",\"passes_free_kicks\",\"through_balls\",\"passes_pressure\",\"passes_switches\",\"crosses\",\"corner_kicks\",\"corner_kicks_in\",\"corner_kicks_out\",\"corner_kicks_straight\",\"passes_ground\",\"passes_low\",\"passes_high\",\"passes_left_foot\",\"passes_right_foot\",\"passes_head\",\"throw_ins\",\"passes_other_body\",\"passes_completed\",\"passes_offsides\",\"passes_oob\",\"passes_intercepted\",\"passes_blocked\"]\n", "passing_types2 = [\"passes\",\"passes_live\",\"passes_dead\",\"passes_free_kicks\",\"through_balls\",\"passes_pressure\",\"passes_switches\",\"crosses\",\"corner_kicks\",\"corner_kicks_in\",\"corner_kicks_out\",\"corner_kicks_straight\",\"passes_ground\",\"passes_low\",\"passes_high\",\"passes_left_foot\",\"passes_right_foot\",\"passes_head\",\"throw_ins\",\"passes_other_body\",\"passes_completed\",\"passes_offsides\",\"passes_oob\",\"passes_intercepted\",\"passes_blocked\"]\n", "#goal and shot creation(gca)\n", "gca = [\"player\",\"nationality\",\"position\",\"squad\",\"age\",\"birth_year\",\"minutes_90s\",\"sca\",\"sca_per90\",\"sca_passes_live\",\"sca_passes_dead\",\"sca_dribbles\",\"sca_shots\",\"sca_fouled\",\"gca\",\"gca_per90\",\"gca_passes_live\",\"gca_passes_dead\",\"gca_dribbles\",\"gca_shots\",\"gca_fouled\",\"gca_og_for\"]\n", "gca2 = [\"sca\",\"sca_per90\",\"sca_passes_live\",\"sca_passes_dead\",\"sca_dribbles\",\"sca_shots\",\"sca_fouled\",\"gca\",\"gca_per90\",\"gca_passes_live\",\"gca_passes_dead\",\"gca_dribbles\",\"gca_shots\",\"gca_fouled\",\"gca_og_for\"]\n", "#defensive actions(defense)\n", "defense = [\"player\",\"nationality\",\"position\",\"squad\",\"age\",\"birth_year\",\"minutes_90s\",\"tackles\",\"tackles_won\",\"tackles_def_3rd\",\"tackles_mid_3rd\",\"tackles_att_3rd\",\"dribble_tackles\",\"dribbles_vs\",\"dribble_tackles_pct\",\"dribbled_past\",\"pressures\",\"pressure_regains\",\"pressure_regain_pct\",\"pressures_def_3rd\",\"pressures_mid_3rd\",\"pressures_att_3rd\",\"blocks\",\"blocked_shots\",\"blocked_shots_saves\",\"blocked_passes\",\"interceptions\",\"clearances\",\"errors\"]\n", "defense2 = [\"tackles\",\"tackles_won\",\"tackles_def_3rd\",\"tackles_mid_3rd\",\"tackles_att_3rd\",\"dribble_tackles\",\"dribbles_vs\",\"dribble_tackles_pct\",\"dribbled_past\",\"pressures\",\"pressure_regains\",\"pressure_regain_pct\",\"pressures_def_3rd\",\"pressures_mid_3rd\",\"pressures_att_3rd\",\"blocks\",\"blocked_shots\",\"blocked_shots_saves\",\"blocked_passes\",\"interceptions\",\"clearances\",\"errors\"]\n", "#possession(possession)\n", "possession = [\"player\",\"nationality\",\"position\",\"squad\",\"age\",\"birth_year\",\"minutes_90s\",\"touches\",\"touches_def_pen_area\",\"touches_def_3rd\",\"touches_mid_3rd\",\"touches_att_3rd\",\"touches_att_pen_area\",\"touches_live_ball\",\"dribbles_completed\",\"dribbles\",\"dribbles_completed_pct\",\"players_dribbled_past\",\"nutmegs\",\"carries\",\"carry_distance\",\"carry_progressive_distance\",\"pass_targets\",\"passes_received\",\"passes_received_pct\",\"miscontrols\",\"dispossessed\"]\n", "possession2 = [\"touches\",\"touches_def_pen_area\",\"touches_def_3rd\",\"touches_mid_3rd\",\"touches_att_3rd\",\"touches_att_pen_area\",\"touches_live_ball\",\"dribbles_completed\",\"dribbles\",\"dribbles_completed_pct\",\"players_dribbled_past\",\"nutmegs\",\"carries\",\"carry_distance\",\"carry_progressive_distance\",\"pass_targets\",\"passes_received\",\"passes_received_pct\",\"miscontrols\",\"dispossessed\"]\n", "#playingtime(playingtime)\n", "playingtime = [\"player\",\"nationality\",\"position\",\"squad\",\"age\",\"birth_year\",\"minutes_90s\",\"games\",\"minutes\",\"minutes_per_game\",\"minutes_pct\",\"games_starts\",\"minutes_per_start\",\"games_subs\",\"minutes_per_sub\",\"unused_subs\",\"points_per_match\",\"on_goals_for\",\"on_goals_against\",\"plus_minus\",\"plus_minus_per90\",\"plus_minus_wowy\",\"on_xg_for\",\"on_xg_against\",\"xg_plus_minus\",\"xg_plus_minus_per90\",\"xg_plus_minus_wowy\"]\n", "playingtime2 = [\"games\",\"minutes\",\"minutes_per_game\",\"minutes_pct\",\"games_starts\",\"minutes_per_start\",\"games_subs\",\"minutes_per_sub\",\"unused_subs\",\"points_per_match\",\"on_goals_for\",\"on_goals_against\",\"plus_minus\",\"plus_minus_per90\",\"plus_minus_wowy\",\"on_xg_for\",\"on_xg_against\",\"xg_plus_minus\",\"xg_plus_minus_per90\",\"xg_plus_minus_wowy\"]\n", "#miscallaneous(misc)\n", "misc = [\"player\",\"nationality\",\"position\",\"squad\",\"age\",\"birth_year\",\"minutes_90s\",\"cards_yellow\",\"cards_red\",\"cards_yellow_red\",\"fouls\",\"fouled\",\"offsides\",\"crosses\",\"interceptions\",\"tackles_won\",\"pens_won\",\"pens_conceded\",\"own_goals\",\"ball_recoveries\",\"aerials_won\",\"aerials_lost\",\"aerials_won_pct\"]\n", "misc2 = [\"cards_yellow\",\"cards_red\",\"cards_yellow_red\",\"fouls\",\"fouled\",\"offsides\",\"crosses\",\"interceptions\",\"tackles_won\",\"pens_won\",\"pens_conceded\",\"own_goals\",\"ball_recoveries\",\"aerials_won\",\"aerials_lost\",\"aerials_won_pct\"]" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import requests\n", "from bs4 import BeautifulSoup\n", "import pandas as pd\n", "import re\n", "import sys, getopt\n", "import csv" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "#Functions to get the data in a dataframe using BeautifulSoup\n", "\n", "def get_tables(url):\n", " res = requests.get(url)\n", " ## The next two lines get around the issue with comments breaking the parsing.\n", " comm = re.compile(\"\")\n", " soup = BeautifulSoup(comm.sub(\"\",res.text),'lxml')\n", " all_tables = soup.findAll(\"tbody\")\n", " team_table = all_tables[0]\n", " player_table = all_tables[1]\n", " return player_table, team_table\n", "\n", "def get_frame(features, player_table):\n", " pre_df_player = dict()\n", " features_wanted_player = features\n", " rows_player = player_table.find_all('tr')\n", " for row in rows_player:\n", " if(row.find('th',{\"scope\":\"row\"}) != None):\n", " \n", " for f in features_wanted_player:\n", " cell = row.find(\"td\",{\"data-stat\": f})\n", " a = cell.text.strip().encode()\n", " text=a.decode(\"utf-8\")\n", " if(text == ''):\n", " text = '0'\n", " if((f!='player')&(f!='nationality')&(f!='position')&(f!='squad')&(f!='age')&(f!='birth_year')):\n", " text = float(text.replace(',',''))\n", " if f in pre_df_player:\n", " pre_df_player[f].append(text)\n", " else:\n", " pre_df_player[f] = [text]\n", " df_player = pd.DataFrame.from_dict(pre_df_player)\n", " return df_player\n", "\n", "def get_frame_team(features, team_table):\n", " pre_df_squad = dict()\n", " #Note: features does not contain squad name, it requires special treatment\n", " features_wanted_squad = features\n", " rows_squad = team_table.find_all('tr')\n", " for row in rows_squad:\n", " if(row.find('th',{\"scope\":\"row\"}) != None):\n", " name = row.find('th',{\"data-stat\":\"squad\"}).text.strip().encode().decode(\"utf-8\")\n", " if 'squad' in pre_df_squad:\n", " pre_df_squad['squad'].append(name)\n", " else:\n", " pre_df_squad['squad'] = [name]\n", " for f in features_wanted_squad:\n", " cell = row.find(\"td\",{\"data-stat\": f})\n", " a = cell.text.strip().encode()\n", " text=a.decode(\"utf-8\")\n", " if(text == ''):\n", " text = '0'\n", " if((f!='player')&(f!='nationality')&(f!='position')&(f!='squad')&(f!='age')&(f!='birth_year')):\n", " text = float(text.replace(',',''))\n", " if f in pre_df_squad:\n", " pre_df_squad[f].append(text)\n", " else:\n", " pre_df_squad[f] = [text]\n", " df_squad = pd.DataFrame.from_dict(pre_df_squad)\n", " return df_squad\n", "\n", "def frame_for_category(category,top,end,features):\n", " url = (top + category + end)\n", " player_table, team_table = get_tables(url)\n", " df_player = get_frame(features, player_table)\n", " return df_player\n", "\n", "def frame_for_category_team(category,top,end,features):\n", " url = (top + category + end)\n", " player_table, team_table = get_tables(url)\n", " df_team = get_frame_team(features, team_table)\n", " return df_team" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "#Function to get the player data for outfield player, includes all categories - standard stats, shooting\n", "#passing, passing types, goal and shot creation, defensive actions, possession, and miscallaneous\n", "def get_outfield_data(top, end):\n", " df1 = frame_for_category('stats',top,end,stats)\n", " df2 = frame_for_category('shooting',top,end,shooting2)\n", " df3 = frame_for_category('passing',top,end,passing2)\n", " df4 = frame_for_category('passing_types',top,end,passing_types2)\n", " df5 = frame_for_category('gca',top,end,gca2)\n", " df6 = frame_for_category('defense',top,end,defense2)\n", " df7 = frame_for_category('possession',top,end,possession2)\n", " df8 = frame_for_category('misc',top,end,misc2)\n", " df = pd.concat([df1, df2, df3, df4, df5, df6, df7, df8], axis=1)\n", " df = df.loc[:,~df.columns.duplicated()]\n", " return df" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "#Function to get keeping and advance goalkeeping data\n", "def get_keeper_data(top,end):\n", " df1 = frame_for_category('keepers',top,end,keepers)\n", " df2 = frame_for_category('keepersadv',top,end,keepersadv2)\n", " df = pd.concat([df1, df2], axis=1)\n", " df = df.loc[:,~df.columns.duplicated()]\n", " return df" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "#Function to get team-wise data accross all categories as mentioned above\n", "def get_team_data(top,end):\n", " df1 = frame_for_category_team('stats',top,end,stats3)\n", " df2 = frame_for_category_team('keepers',top,end,keepers3)\n", " df3 = frame_for_category_team('keepersadv',top,end,keepersadv2)\n", " df4 = frame_for_category_team('shooting',top,end,shooting3)\n", " df5 = frame_for_category_team('passing',top,end,passing2)\n", " df6 = frame_for_category_team('passing_types',top,end,passing_types2)\n", " df7 = frame_for_category_team('gca',top,end,gca2)\n", " df8 = frame_for_category_team('defense',top,end,defense2)\n", " df9 = frame_for_category_team('possession',top,end,possession2)\n", " df10 = frame_for_category_team('misc',top,end,misc2)\n", " df = pd.concat([df1, df2, df3, df4, df5, df6, df7, df8, df9, df10], axis=1)\n", " df = df.loc[:,~df.columns.duplicated()]\n", " return df\n", " " ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
playernationalitypositionsquadagebirth_yeargamesgames_startsminutesgoals...foulsfouledoffsidespens_wonpens_concededown_goalsball_recoveriesaerials_wonaerials_lostaerials_won_pct
0Patrick van Aanholtnl NEDDFCrystal Palace28199025.025.02162.03.0...6.06.02.00.00.01.0203.010.014.041.7
1Max Aaronseng ENGDFNorwich City19200030.030.02700.00.0...26.040.02.01.00.00.0236.018.036.033.3
2Tammy Abrahameng ENGFWChelsea21199728.024.02034.013.0...16.021.023.01.00.01.086.058.097.037.4
3Che Adamseng ENGFWSouthampton23199624.08.0756.00.0...14.08.07.01.00.00.054.018.058.023.7
4Adriánes ESPGKLiverpool32198711.09.0875.00.0...0.01.00.00.00.00.047.00.00.00.0
..................................................................
503Wilfried Zahaci CIVMF,FWCrystal Palace26199232.031.02740.03.0...42.099.015.01.00.00.0208.011.025.030.6
504Christoph Zimmermannde GERDFNorwich City26199315.015.01295.00.0...8.08.00.00.02.00.0139.036.010.078.3
505Oleksandr Zinchenkoua UKRDFManchester City22199614.011.01028.00.0...11.02.00.00.00.00.0119.023.019.054.8
506Richairo Živkovićnl NEDFWSheffield Utd2219962.00.044.00.0...1.00.00.00.00.00.00.01.04.020.0
507Kurt Zoumafr FRADFChelsea24199422.019.01804.00.0...26.012.01.00.01.01.0240.076.022.077.6
\n", "

508 rows × 151 columns

\n", "
" ], "text/plain": [ " player nationality position squad age \\\n", "0 Patrick van Aanholt nl NED DF Crystal Palace 28 \n", "1 Max Aarons eng ENG DF Norwich City 19 \n", "2 Tammy Abraham eng ENG FW Chelsea 21 \n", "3 Che Adams eng ENG FW Southampton 23 \n", "4 Adrián es ESP GK Liverpool 32 \n", ".. ... ... ... ... .. \n", "503 Wilfried Zaha ci CIV MF,FW Crystal Palace 26 \n", "504 Christoph Zimmermann de GER DF Norwich City 26 \n", "505 Oleksandr Zinchenko ua UKR DF Manchester City 22 \n", "506 Richairo Živković nl NED FW Sheffield Utd 22 \n", "507 Kurt Zouma fr FRA DF Chelsea 24 \n", "\n", " birth_year games games_starts minutes goals ... fouls fouled \\\n", "0 1990 25.0 25.0 2162.0 3.0 ... 6.0 6.0 \n", "1 2000 30.0 30.0 2700.0 0.0 ... 26.0 40.0 \n", "2 1997 28.0 24.0 2034.0 13.0 ... 16.0 21.0 \n", "3 1996 24.0 8.0 756.0 0.0 ... 14.0 8.0 \n", "4 1987 11.0 9.0 875.0 0.0 ... 0.0 1.0 \n", ".. ... ... ... ... ... ... ... ... \n", "503 1992 32.0 31.0 2740.0 3.0 ... 42.0 99.0 \n", "504 1993 15.0 15.0 1295.0 0.0 ... 8.0 8.0 \n", "505 1996 14.0 11.0 1028.0 0.0 ... 11.0 2.0 \n", "506 1996 2.0 0.0 44.0 0.0 ... 1.0 0.0 \n", "507 1994 22.0 19.0 1804.0 0.0 ... 26.0 12.0 \n", "\n", " offsides pens_won pens_conceded own_goals ball_recoveries \\\n", "0 2.0 0.0 0.0 1.0 203.0 \n", "1 2.0 1.0 0.0 0.0 236.0 \n", "2 23.0 1.0 0.0 1.0 86.0 \n", "3 7.0 1.0 0.0 0.0 54.0 \n", "4 0.0 0.0 0.0 0.0 47.0 \n", ".. ... ... ... ... ... \n", "503 15.0 1.0 0.0 0.0 208.0 \n", "504 0.0 0.0 2.0 0.0 139.0 \n", "505 0.0 0.0 0.0 0.0 119.0 \n", "506 0.0 0.0 0.0 0.0 0.0 \n", "507 1.0 0.0 1.0 1.0 240.0 \n", "\n", " aerials_won aerials_lost aerials_won_pct \n", "0 10.0 14.0 41.7 \n", "1 18.0 36.0 33.3 \n", "2 58.0 97.0 37.4 \n", "3 18.0 58.0 23.7 \n", "4 0.0 0.0 0.0 \n", ".. ... ... ... \n", "503 11.0 25.0 30.6 \n", "504 36.0 10.0 78.3 \n", "505 23.0 19.0 54.8 \n", "506 1.0 4.0 20.0 \n", "507 76.0 22.0 77.6 \n", "\n", "[508 rows x 151 columns]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Go to the 'Standard stats' page of the league\n", "#For Premier League 2019/20, the link is this: https://fbref.com/en/comps/9/stats/Premier-League-Stats\n", "#Remove the 'stats', and pass the first and third part of the link as parameters like below\n", "df_outfield = get_outfield_data('https://fbref.com/en/comps/9/','/Premier-League-Stats')\n", "df_outfield" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
squadplayers_usedpossessiongamesgames_startsminutesgoalsassistspens_madepens_att...foulsfouledoffsidespens_wonpens_concededown_goalsball_recoveriesaerials_wonaerials_lostaerials_won_pct
0Arsenal29.054.832.0352.02880.047.029.02.02.0...346.0367.063.01.05.00.02593.0403.0471.046.1
1Aston Villa28.045.232.0352.02880.035.028.01.03.0...376.0425.051.02.05.01.02860.0581.0644.047.4
2Bournemouth27.045.532.0352.02880.029.019.01.01.0...304.0331.054.01.03.00.03031.0627.0663.048.6
3Brighton25.054.032.0352.02880.030.020.01.02.0...324.0269.055.02.02.02.03010.0549.0468.054.0
4Burnley22.040.332.0352.02880.035.025.02.02.0...356.0320.073.01.05.01.03022.0786.0746.051.3
5Chelsea27.060.032.0352.02880.057.037.06.06.0...330.0319.056.05.02.03.03129.0552.0539.050.6
6Crystal Palace24.044.232.0352.02880.026.018.03.03.0...349.0393.048.02.01.02.02938.0604.0622.049.3
7Everton23.048.932.0352.02880.038.028.01.01.0...387.0324.051.00.01.02.03067.0708.0720.049.6
8Leicester City21.057.732.0352.02880.058.042.05.07.0...340.0380.057.06.08.00.02942.0565.0496.053.3
9Liverpool24.063.132.0352.02880.068.056.05.05.0...268.0244.045.04.01.01.03309.0539.0473.053.3
10Manchester City23.065.632.0352.02880.080.058.06.010.0...311.0249.056.09.02.01.02874.0423.0390.052.0
11Manchester Utd28.055.632.0352.02880.050.034.07.011.0...357.0365.045.010.01.01.02979.0499.0425.054.0
12Newcastle Utd27.037.932.0352.02880.033.025.00.01.0...310.0347.067.00.00.01.02816.0625.0643.049.3
13Norwich City28.050.232.0352.02880.024.017.02.02.0...306.0371.041.01.07.02.02868.0443.0552.044.5
14Sheffield Utd25.043.532.0352.02880.030.021.01.01.0...346.0249.066.01.02.00.03093.0736.0725.050.4
15Southampton24.047.932.0352.02880.041.024.01.02.0...389.0319.049.02.04.01.03341.0683.0758.047.4
16Tottenham29.053.132.0352.02880.048.033.03.04.0...338.0359.057.04.07.02.03081.0529.0539.049.5
17Watford26.042.632.0352.02880.028.019.04.05.0...398.0272.054.04.06.03.03176.0664.0666.049.9
18West Ham28.043.232.0352.02880.038.029.03.03.0...324.0289.063.03.06.03.02973.0659.0669.049.6
19Wolves20.047.732.0352.02880.043.031.03.03.0...350.0304.045.03.02.01.02992.0617.0583.051.4
\n", "

20 rows × 188 columns

\n", "
" ], "text/plain": [ " squad players_used possession games games_starts minutes \\\n", "0 Arsenal 29.0 54.8 32.0 352.0 2880.0 \n", "1 Aston Villa 28.0 45.2 32.0 352.0 2880.0 \n", "2 Bournemouth 27.0 45.5 32.0 352.0 2880.0 \n", "3 Brighton 25.0 54.0 32.0 352.0 2880.0 \n", "4 Burnley 22.0 40.3 32.0 352.0 2880.0 \n", "5 Chelsea 27.0 60.0 32.0 352.0 2880.0 \n", "6 Crystal Palace 24.0 44.2 32.0 352.0 2880.0 \n", "7 Everton 23.0 48.9 32.0 352.0 2880.0 \n", "8 Leicester City 21.0 57.7 32.0 352.0 2880.0 \n", "9 Liverpool 24.0 63.1 32.0 352.0 2880.0 \n", "10 Manchester City 23.0 65.6 32.0 352.0 2880.0 \n", "11 Manchester Utd 28.0 55.6 32.0 352.0 2880.0 \n", "12 Newcastle Utd 27.0 37.9 32.0 352.0 2880.0 \n", "13 Norwich City 28.0 50.2 32.0 352.0 2880.0 \n", "14 Sheffield Utd 25.0 43.5 32.0 352.0 2880.0 \n", "15 Southampton 24.0 47.9 32.0 352.0 2880.0 \n", "16 Tottenham 29.0 53.1 32.0 352.0 2880.0 \n", "17 Watford 26.0 42.6 32.0 352.0 2880.0 \n", "18 West Ham 28.0 43.2 32.0 352.0 2880.0 \n", "19 Wolves 20.0 47.7 32.0 352.0 2880.0 \n", "\n", " goals assists pens_made pens_att ... fouls fouled offsides \\\n", "0 47.0 29.0 2.0 2.0 ... 346.0 367.0 63.0 \n", "1 35.0 28.0 1.0 3.0 ... 376.0 425.0 51.0 \n", "2 29.0 19.0 1.0 1.0 ... 304.0 331.0 54.0 \n", "3 30.0 20.0 1.0 2.0 ... 324.0 269.0 55.0 \n", "4 35.0 25.0 2.0 2.0 ... 356.0 320.0 73.0 \n", "5 57.0 37.0 6.0 6.0 ... 330.0 319.0 56.0 \n", "6 26.0 18.0 3.0 3.0 ... 349.0 393.0 48.0 \n", "7 38.0 28.0 1.0 1.0 ... 387.0 324.0 51.0 \n", "8 58.0 42.0 5.0 7.0 ... 340.0 380.0 57.0 \n", "9 68.0 56.0 5.0 5.0 ... 268.0 244.0 45.0 \n", "10 80.0 58.0 6.0 10.0 ... 311.0 249.0 56.0 \n", "11 50.0 34.0 7.0 11.0 ... 357.0 365.0 45.0 \n", "12 33.0 25.0 0.0 1.0 ... 310.0 347.0 67.0 \n", "13 24.0 17.0 2.0 2.0 ... 306.0 371.0 41.0 \n", "14 30.0 21.0 1.0 1.0 ... 346.0 249.0 66.0 \n", "15 41.0 24.0 1.0 2.0 ... 389.0 319.0 49.0 \n", "16 48.0 33.0 3.0 4.0 ... 338.0 359.0 57.0 \n", "17 28.0 19.0 4.0 5.0 ... 398.0 272.0 54.0 \n", "18 38.0 29.0 3.0 3.0 ... 324.0 289.0 63.0 \n", "19 43.0 31.0 3.0 3.0 ... 350.0 304.0 45.0 \n", "\n", " pens_won pens_conceded own_goals ball_recoveries aerials_won \\\n", "0 1.0 5.0 0.0 2593.0 403.0 \n", "1 2.0 5.0 1.0 2860.0 581.0 \n", "2 1.0 3.0 0.0 3031.0 627.0 \n", "3 2.0 2.0 2.0 3010.0 549.0 \n", "4 1.0 5.0 1.0 3022.0 786.0 \n", "5 5.0 2.0 3.0 3129.0 552.0 \n", "6 2.0 1.0 2.0 2938.0 604.0 \n", "7 0.0 1.0 2.0 3067.0 708.0 \n", "8 6.0 8.0 0.0 2942.0 565.0 \n", "9 4.0 1.0 1.0 3309.0 539.0 \n", "10 9.0 2.0 1.0 2874.0 423.0 \n", "11 10.0 1.0 1.0 2979.0 499.0 \n", "12 0.0 0.0 1.0 2816.0 625.0 \n", "13 1.0 7.0 2.0 2868.0 443.0 \n", "14 1.0 2.0 0.0 3093.0 736.0 \n", "15 2.0 4.0 1.0 3341.0 683.0 \n", "16 4.0 7.0 2.0 3081.0 529.0 \n", "17 4.0 6.0 3.0 3176.0 664.0 \n", "18 3.0 6.0 3.0 2973.0 659.0 \n", "19 3.0 2.0 1.0 2992.0 617.0 \n", "\n", " aerials_lost aerials_won_pct \n", "0 471.0 46.1 \n", "1 644.0 47.4 \n", "2 663.0 48.6 \n", "3 468.0 54.0 \n", "4 746.0 51.3 \n", "5 539.0 50.6 \n", "6 622.0 49.3 \n", "7 720.0 49.6 \n", "8 496.0 53.3 \n", "9 473.0 53.3 \n", "10 390.0 52.0 \n", "11 425.0 54.0 \n", "12 643.0 49.3 \n", "13 552.0 44.5 \n", "14 725.0 50.4 \n", "15 758.0 47.4 \n", "16 539.0 49.5 \n", "17 666.0 49.9 \n", "18 669.0 49.6 \n", "19 583.0 51.4 \n", "\n", "[20 rows x 188 columns]" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Go to the 'Standard stats' page of the league\n", "#For Premier League 2019/20, the link is this: https://fbref.com/en/comps/9/stats/Premier-League-Stats\n", "#Remove the 'stats', and pass the first and third part of the link as parameters like below\n", "df_team = get_team_data('https://fbref.com/en/comps/9/','/Premier-League-Stats')\n", "df_team" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "#Save csv file to Desktop\n", "df_team.to_csv('PL1920_Team.csv')" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "scrolled": false }, "outputs": [ { "data": { "text/html": [ "
\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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
playernationalitypositionsquadagebirth_yeargames_gkgames_starts_gkminutes_gkgoals_against_gk...passes_length_avg_gkgoal_kickspct_goal_kicks_launchedgoal_kick_length_avgcrosses_gkcrosses_stopped_gkcrosses_stopped_pct_gkdef_actions_outside_pen_area_gkdef_actions_outside_pen_area_per90_gkavg_distance_def_actions_gk
0Antonio Adánes ESPGKAtlético Madrid3219871.00.025.00.0...44.01.0100.067.02.00.00.01.03.6014.7
1Adriánes ESPGKLiverpool32198711.09.0875.010.0...38.368.048.540.491.08.08.87.00.7213.3
2Rúnar Alex Rúnarssonis ISLGKDijon24199511.09.0900.017.0...35.981.064.249.289.08.09.05.00.5014.1
3Enrico Alfonsoit ITAGKBrescia3119884.04.0279.04.0...37.024.037.532.838.02.05.34.01.2916.3
4Alissonbr BRAGKLiverpool26199223.023.02003.015.0...31.9141.039.739.1151.010.06.625.01.1217.1
..................................................................
186Mauro Vigoritoit ITAGKLecce2919905.04.0423.09.0...36.349.038.832.261.04.06.61.00.2111.6
187Felix Wiedwaldde GERGKEint Frankfurt2919903.03.0270.08.0...38.024.054.241.828.02.07.13.01.0016.1
188Yoeles ESPGKEibar3019882.02.090.00.0...61.28.087.566.516.01.06.32.02.0017.0
189Robin Zentnerde GERGKMainz 0524199422.022.01935.040.0...40.8196.062.851.6226.023.010.220.00.9316.2
190Leopold Zingerlede GERGKPaderborn 0725199428.028.02520.057.0...32.3235.031.932.5260.010.03.817.00.6114.0
\n", "

191 rows × 47 columns

\n", "
" ], "text/plain": [ " player nationality position squad age \\\n", "0 Antonio Adán es ESP GK Atlético Madrid 32 \n", "1 Adrián es ESP GK Liverpool 32 \n", "2 Rúnar Alex Rúnarsson is ISL GK Dijon 24 \n", "3 Enrico Alfonso it ITA GK Brescia 31 \n", "4 Alisson br BRA GK Liverpool 26 \n", ".. ... ... ... ... .. \n", "186 Mauro Vigorito it ITA GK Lecce 29 \n", "187 Felix Wiedwald de GER GK Eint Frankfurt 29 \n", "188 Yoel es ESP GK Eibar 30 \n", "189 Robin Zentner de GER GK Mainz 05 24 \n", "190 Leopold Zingerle de GER GK Paderborn 07 25 \n", "\n", " birth_year games_gk games_starts_gk minutes_gk goals_against_gk ... \\\n", "0 1987 1.0 0.0 25.0 0.0 ... \n", "1 1987 11.0 9.0 875.0 10.0 ... \n", "2 1995 11.0 9.0 900.0 17.0 ... \n", "3 1988 4.0 4.0 279.0 4.0 ... \n", "4 1992 23.0 23.0 2003.0 15.0 ... \n", ".. ... ... ... ... ... ... \n", "186 1990 5.0 4.0 423.0 9.0 ... \n", "187 1990 3.0 3.0 270.0 8.0 ... \n", "188 1988 2.0 2.0 90.0 0.0 ... \n", "189 1994 22.0 22.0 1935.0 40.0 ... \n", "190 1994 28.0 28.0 2520.0 57.0 ... \n", "\n", " passes_length_avg_gk goal_kicks pct_goal_kicks_launched \\\n", "0 44.0 1.0 100.0 \n", "1 38.3 68.0 48.5 \n", "2 35.9 81.0 64.2 \n", "3 37.0 24.0 37.5 \n", "4 31.9 141.0 39.7 \n", ".. ... ... ... \n", "186 36.3 49.0 38.8 \n", "187 38.0 24.0 54.2 \n", "188 61.2 8.0 87.5 \n", "189 40.8 196.0 62.8 \n", "190 32.3 235.0 31.9 \n", "\n", " goal_kick_length_avg crosses_gk crosses_stopped_gk \\\n", "0 67.0 2.0 0.0 \n", "1 40.4 91.0 8.0 \n", "2 49.2 89.0 8.0 \n", "3 32.8 38.0 2.0 \n", "4 39.1 151.0 10.0 \n", ".. ... ... ... \n", "186 32.2 61.0 4.0 \n", "187 41.8 28.0 2.0 \n", "188 66.5 16.0 1.0 \n", "189 51.6 226.0 23.0 \n", "190 32.5 260.0 10.0 \n", "\n", " crosses_stopped_pct_gk def_actions_outside_pen_area_gk \\\n", "0 0.0 1.0 \n", "1 8.8 7.0 \n", "2 9.0 5.0 \n", "3 5.3 4.0 \n", "4 6.6 25.0 \n", ".. ... ... \n", "186 6.6 1.0 \n", "187 7.1 3.0 \n", "188 6.3 2.0 \n", "189 10.2 20.0 \n", "190 3.8 17.0 \n", "\n", " def_actions_outside_pen_area_per90_gk avg_distance_def_actions_gk \n", "0 3.60 14.7 \n", "1 0.72 13.3 \n", "2 0.50 14.1 \n", "3 1.29 16.3 \n", "4 1.12 17.1 \n", ".. ... ... \n", "186 0.21 11.6 \n", "187 1.00 16.1 \n", "188 2.00 17.0 \n", "189 0.93 16.2 \n", "190 0.61 14.0 \n", "\n", "[191 rows x 47 columns]" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Similar for keepers like above\n", "df_keeper = get_keeper_data('https://fbref.com/en/comps/Big5/','/players/Big-5-European-Leagues-Stats')\n", "df_keeper" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "#Save csv file to Desktop\n", "df_outfield.to_csv('PL1920_Outfield.csv')" ] } ], "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.7.6" }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }