{ "cells": [ { "cell_type": "markdown", "id": "d065632b", "metadata": {}, "source": [ "Scraping from http://fbref.com\n", "\n", "Data:\n", "- outfield players stats\n", "- goalkeepers stats\n", "- team stats (of and against)\n", "\n", "Original code by parth1902:\n", "https://github.com/parth1902/Scrape-FBref-data" ] }, { "cell_type": "code", "execution_count": 1, "id": "3b8d2e7f", "metadata": {}, "outputs": [], "source": [ "import requests\n", "from bs4 import BeautifulSoup\n", "import pandas as pd\n", "import numpy as np\n", "import re\n", "import sys, getopt\n", "import csv\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "ab920c85", "metadata": {}, "outputs": [], "source": [ "#standard(stats)\n", "stats = [\"player\",\"nationality\",\"position\",\"team\",\"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\",\"team\",\"age\",\"birth_year\",\"gk_games\",\"gk_games_starts\",\"gk_minutes\",\"gk_goals_against\",\"gk_goals_against_per90\",\"gk_shots_on_target_against\",\"gk_saves\",\"gk_save_pct\",\"gk_wins\",\"gk_ties\",\"gk_losses\",\"gk_clean_sheets\",\"gk_clean_sheets_pct\",\"gk_pens_att\",\"gk_pens_allowed\",\"gk_pens_saved\",\"gk_pens_missed\"]\n", "keepers3 = [\"players_used\",\"gk_games\",\"gk_games_starts\",\"gk_minutes\",\"gk_goals_against\",\"gk_goals_against_per90\",\"gk_shots_on_target_against\",\"gk_saves\",\"gk_save_pct\",\"gk_wins\",\"gk_ties\",\"gk_losses\",\"gk_clean_sheets\",\"gk_clean_sheets_pct\",\"gk_pens_att\",\"gk_pens_allowed\",\"gk_pens_saved\",\"gk_pens_missed\"]\n", "#advance goalkeeping(keepersadv)\n", "keepersadv = [\"player\",\"nationality\",\"position\",\"team\",\"age\",\"birth_year\",\"minutes_90s\",\"gk_goals_against\",\"gk_pens_allowed\",\"gk_free_kick_goals_against\",\"gk_corner_kick_goals_against\",\"gk_own_goals_against\",\"gk_psxg\",\"gk_psnpxg_per_shot_on_target_against\",\"gk_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\",\"gk_pct_goal_kicks_launched\",\"gk_goal_kick_length_avg\",\"gk_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\"]\n", "keepersadv2 = [\"minutes_90s\",\"gk_goals_against\",\"gk_pens_allowed\",\"gk_free_kick_goals_against\",\"gk_corner_kick_goals_against\",\"gk_own_goals_against\",\"gk_psxg\",\"gk_psnpxg_per_shot_on_target_against\",\"gk_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\",\"gk_pct_goal_kicks_launched\",\"gk_goal_kick_length_avg\",\"gk_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\"]\n", "#shooting(shooting)\n", "shooting = [\"player\",\"nationality\",\"position\",\"team\",\"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\",\"team\",\"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\",\"team\",\"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\",\"team\",\"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_defense\"]\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_defense\"]\n", "#defensive actions(defense)\n", "defense = [\"player\",\"nationality\",\"position\",\"team\",\"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\",\"team\",\"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\",\"progressive_carries\",\"carries_into_final_third\",\"carries_into_penalty_area\",\"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\",\"progressive_carries\",\"carries_into_final_third\",\"carries_into_penalty_area\",\"pass_targets\",\"passes_received\",\"passes_received_pct\",\"miscontrols\",\"dispossessed\"]\n", "#playingtime(playingtime)\n", "playingtime = [\"player\",\"nationality\",\"position\",\"team\",\"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\",\"team\",\"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\"]\n", "\n", "def get_tables(url,text):\n", " headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}\n", "\n", " res = requests.get(url, headers = headers)\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", " \n", " team_table = all_tables[0]\n", " team_vs_table = all_tables[1]\n", " player_table = all_tables[2]\n", " if text == 'for':\n", " return player_table, team_table\n", " if text == 'vs':\n", " return player_table, team_vs_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", " if(cell == None):\n", " continue\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')&(f!='team')):\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\":\"team\"}).text.strip().encode().decode(\"utf-8\")\n", " if 'team' in pre_df_squad:\n", " pre_df_squad['team'].append(name)\n", " else:\n", " pre_df_squad['team'] = [name]\n", " for f in features_wanted_squad:\n", " cell = row.find(\"td\",{\"data-stat\": f})\n", " if(cell == None):\n", " continue\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')&(f!='team')):\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 get_frame_team_2(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')&(f!='team')):\n", " text = float(text.replace(',',''))\n", " print(f)\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,'for')\n", " df_player = get_frame(features, player_table)\n", " return df_player\n", "\n", "def frame_for_category_team(category,top,end,features,text):\n", " url = (top + category + end)\n", " player_table, team_table = get_tables(url,text)\n", " df_team = get_frame_team(features, team_table)\n", " return df_team\n", "\n", "\n", "\n", "\n", "#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\n", "\n", "\n", "#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\n", "\n", "\n", "\n", "#Function to get team-wise data accross all categories as mentioned above\n", "def get_team_data(top,end,text):\n", " df1 = frame_for_category_team('stats',top,end,stats3,text)\n", " df2 = frame_for_category_team('keepers',top,end,keepers3,text)\n", " df3 = frame_for_category_team('keepersadv',top,end,keepersadv2,text)\n", " df4 = frame_for_category_team('shooting',top,end,shooting3,text)\n", " df5 = frame_for_category_team('passing',top,end,passing2,text)\n", " df6 = frame_for_category_team('passing_types',top,end,passing_types2,text)\n", " df7 = frame_for_category_team('gca',top,end,gca2,text)\n", " df8 = frame_for_category_team('defense',top,end,defense2,text)\n", " df9 = frame_for_category_team('possession',top,end,possession2,text)\n", " df10 = frame_for_category_team('misc',top,end,misc2,text)\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" ] }, { "cell_type": "code", "execution_count": 3, "id": "9141a9ec", "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", "
playernationalitypositionteamagebirth_yeargamesgames_startsminutesgoals...foulsfouledoffsidespens_wonpens_concededown_goalsball_recoveriesaerials_wonaerials_lostaerials_won_pct
0James Abankwahie IRLDFUdinese19-10920041.00.05.00.0...1.00.00.00.00.00.00.00.00.00.0
1Oliver Abildgaarddk DENMFHellas Verona26-32919968.04.0377.00.0...9.02.00.00.00.00.024.031.011.073.8
2Tammy Abrahameng ENGFWRoma25-215199733.024.02084.08.0...32.045.011.01.00.00.043.078.071.052.3
3Christian Acellait ITAMFCremonese20-30220021.00.015.00.0...0.00.00.00.00.00.01.00.00.00.0
4Francesco Acerbiit ITADFInter35-084198826.022.02095.00.0...14.010.01.00.00.00.0131.071.035.067.0
..................................................................
576Petar Zovkoba BIHGKSpezia21-04120021.00.074.00.0...0.00.00.00.00.00.02.00.00.00.0
577Szymon Żurkowskipl POLMFFiorentina25-22219972.00.032.00.0...1.00.00.00.00.00.02.01.01.050.0
578Szymon Żurkowskipl POLMFSpezia25-22219976.02.0240.00.0...8.05.00.00.00.00.018.03.02.060.0
579Milan Đurićba BIHFWHellas Verona32-348199023.09.0974.01.0...22.020.04.00.00.00.023.0146.038.079.3
580Filip Đuričićrs SRBMF,FWSampdoria31-095199229.024.01911.03.0...31.043.00.00.00.00.099.012.022.035.3
\n", "

581 rows × 115 columns

\n", "
" ], "text/plain": [ " player nationality position team age birth_year \\\n", "0 James Abankwah ie IRL DF Udinese 19-109 2004 \n", "1 Oliver Abildgaard dk DEN MF Hellas Verona 26-329 1996 \n", "2 Tammy Abraham eng ENG FW Roma 25-215 1997 \n", "3 Christian Acella it ITA MF Cremonese 20-302 2002 \n", "4 Francesco Acerbi it ITA DF Inter 35-084 1988 \n", ".. ... ... ... ... ... ... \n", "576 Petar Zovko ba BIH GK Spezia 21-041 2002 \n", "577 Szymon Żurkowski pl POL MF Fiorentina 25-222 1997 \n", "578 Szymon Żurkowski pl POL MF Spezia 25-222 1997 \n", "579 Milan Đurić ba BIH FW Hellas Verona 32-348 1990 \n", "580 Filip Đuričić rs SRB MF,FW Sampdoria 31-095 1992 \n", "\n", " games games_starts minutes goals ... fouls fouled offsides \\\n", "0 1.0 0.0 5.0 0.0 ... 1.0 0.0 0.0 \n", "1 8.0 4.0 377.0 0.0 ... 9.0 2.0 0.0 \n", "2 33.0 24.0 2084.0 8.0 ... 32.0 45.0 11.0 \n", "3 1.0 0.0 15.0 0.0 ... 0.0 0.0 0.0 \n", "4 26.0 22.0 2095.0 0.0 ... 14.0 10.0 1.0 \n", ".. ... ... ... ... ... ... ... ... \n", "576 1.0 0.0 74.0 0.0 ... 0.0 0.0 0.0 \n", "577 2.0 0.0 32.0 0.0 ... 1.0 0.0 0.0 \n", "578 6.0 2.0 240.0 0.0 ... 8.0 5.0 0.0 \n", "579 23.0 9.0 974.0 1.0 ... 22.0 20.0 4.0 \n", "580 29.0 24.0 1911.0 3.0 ... 31.0 43.0 0.0 \n", "\n", " pens_won pens_conceded own_goals ball_recoveries aerials_won \\\n", "0 0.0 0.0 0.0 0.0 0.0 \n", "1 0.0 0.0 0.0 24.0 31.0 \n", "2 1.0 0.0 0.0 43.0 78.0 \n", "3 0.0 0.0 0.0 1.0 0.0 \n", "4 0.0 0.0 0.0 131.0 71.0 \n", ".. ... ... ... ... ... \n", "576 0.0 0.0 0.0 2.0 0.0 \n", "577 0.0 0.0 0.0 2.0 1.0 \n", "578 0.0 0.0 0.0 18.0 3.0 \n", "579 0.0 0.0 0.0 23.0 146.0 \n", "580 0.0 0.0 0.0 99.0 12.0 \n", "\n", " aerials_lost aerials_won_pct \n", "0 0.0 0.0 \n", "1 11.0 73.8 \n", "2 71.0 52.3 \n", "3 0.0 0.0 \n", "4 35.0 67.0 \n", ".. ... ... \n", "576 0.0 0.0 \n", "577 1.0 50.0 \n", "578 2.0 60.0 \n", "579 38.0 79.3 \n", "580 22.0 35.3 \n", "\n", "[581 rows x 115 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_outfield = get_outfield_data('https://fbref.com/en/comps/11/','/Serie-A-Stats')\n", "\n", "df_outfield.to_csv('fbref_data/outfield_players.csv', index=False)\n", "\n", "df_outfield" ] }, { "cell_type": "code", "execution_count": 4, "id": "9a30e27c", "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
playernationalitypositionteamagebirth_yeargk_gamesgk_games_startsgk_minutesgk_goals_against...gk_passes_length_avggk_goal_kicksgk_pct_goal_kicks_launchedgk_goal_kick_length_avggk_crossesgk_crosses_stoppedgk_crosses_stopped_pctgk_def_actions_outside_pen_areagk_def_actions_outside_pen_area_per90gk_avg_distance_def_actions
0Emil Auderoit ITAGKSampdoria26-107199725.025.02250.039.0...39.1200.057.044.2356.024.06.723.00.9213.9
1Francesco Bardiit ITAGKBologna31-10719921.01.090.00.0...35.69.044.433.410.00.00.00.00.000.0
2Marco Carnesecchiit ITAGKCremonese22-308200024.024.02160.040.0...41.4179.065.952.8351.028.08.024.01.0013.9
3Michele Cerofoliniit ITAGKFiorentina24-12119991.01.090.00.0...31.13.0100.056.32.00.00.00.00.005.0
4Andrea Consigliit ITAGKSassuolo36-098198731.031.02790.046.0...33.8265.031.332.8424.026.06.126.00.8413.9
5Alessio Cragnoit ITAGKMonza28-31119941.01.090.03.0...22.66.016.733.37.00.00.02.02.0025.7
6Michele Di Gregorioit ITAGKMonza25-282199732.032.02880.041.0...32.6209.037.334.7469.013.02.827.00.8413.3
7Bartłomiej Drągowskipl POLGKSpezia25-259199730.030.02586.048.0...34.1179.060.947.3428.013.03.032.01.1114.2
8Wladimiro Falconeit ITAGKLecce28-023199533.033.02970.040.0...41.7239.076.652.3470.022.04.737.01.1214.1
9Pierluigi Golliniit ITAGKFiorentina28-04819953.03.0270.02.0...32.411.063.649.324.01.04.20.00.009.3
10Pierluigi Golliniit ITAGKNapoli28-04819951.01.090.00.0...31.75.00.015.412.01.08.30.00.002.0
11Samir Handanovićsi SVNGKInter38-295198412.012.01080.016.0...24.764.07.824.4121.02.01.710.00.8316.2
12Mike Maignanfr FRAGKMilan27-306199517.017.01530.017.0...30.860.033.335.1164.012.07.328.01.6518.3
13Federico Marchettiit ITAGKSpezia40-08719831.00.066.02.0...24.38.037.532.48.00.00.01.01.3622.0
14Luís Maximianopt PORGKLazio24-12019991.01.05.00.0...0.00.00.00.00.00.00.00.00.0019.0
15Alex Meretit ITAGKNapoli26-044199732.032.02880.023.0...26.3194.020.126.8320.011.03.435.01.0916.9
16Vanja Milinković-Savićrs SRBGKTorino26-074199733.033.02970.038.0...39.6251.091.269.7407.027.06.666.02.0017.2
17Lorenzo Montipòit ITAGKHellas Verona27-074199632.032.02880.051.0...44.3243.069.150.3430.025.05.851.01.5915.5
18Juan Mussoar ARGGKAtalanta28-364199424.024.02077.027.0...32.1157.062.448.6253.014.05.524.01.0415.6
19Guillermo Ochoamx MEXGKSalernitana37-296198516.016.01440.027.0...41.9164.068.949.0260.08.03.17.00.4411.6
20André Onanacm CMRGKInter27-033199621.021.01890.019.0...29.9132.032.635.9240.014.05.89.00.4312.5
21Rui Patríciopt PORGKRoma35-079198833.033.02970.031.0...33.5230.037.035.1387.015.03.925.00.7613.9
22Gianluca Pegoloit ITAGKSassuolo42-04119812.02.0180.03.0...29.716.031.328.328.02.07.10.00.009.0
23Simone Perilliit ITAGKHellas Verona28-11819951.01.090.00.0...57.313.0100.069.819.01.05.31.01.0012.0
24Mattia Perinit ITAGKJuventus30-176199210.09.0858.07.0...31.160.041.736.5148.04.02.711.01.1515.7
25Samuele Perisanit ITAGKEmpoli25-25719977.07.0630.09.0...32.775.034.734.3134.05.03.74.00.5711.6
26Ivan Provedelit ITAGKLazio29-049199433.032.02963.024.0...33.1167.036.534.9433.018.04.246.01.4016.0
27Ionuț Raduro ROUGKCremonese25-34219979.09.0810.019.0...37.367.050.746.3107.06.05.69.01.0014.5
28Nicola Ravagliait ITAGKSampdoria34-14419886.06.0540.015.0...37.674.051.437.7112.06.05.41.00.1711.0
29Luigi Sepeit ITAGKSalernitana31-362199117.017.01530.027.0...35.9154.048.741.1222.016.07.213.00.7614.2
30Marco Silvestriit ITAGKUdinese32-064199133.033.02970.041.0...32.7256.036.735.2470.012.02.619.00.5812.3
31Salvatore Siriguit ITAGKFiorentina36-11319871.01.090.00.0...37.78.050.041.812.00.00.02.02.0026.3
32Łukasz Skorupskipl POLGKBologna32-000199132.032.02880.043.0...32.5235.037.034.7422.024.05.723.00.7213.2
33Marco Sportielloit ITAGKAtalanta30-360199210.09.0893.012.0...29.787.073.652.4142.014.09.915.01.5116.0
34Wojciech Szczęsnypl POLGKJuventus33-017199024.024.02112.021.0...34.0129.048.140.6338.09.02.719.00.8115.2
35Ciprian Tătărușanuro ROUGKMilan37-085198616.016.01440.022.0...32.983.051.841.8195.09.04.613.00.8114.4
36Pietro Terraccianoit ITAGKFiorentina33-058199028.028.02520.037.0...33.5186.045.240.2268.012.04.552.01.8618.5
37Martin Turksi SVNGKSampdoria19-25720032.02.0180.05.0...37.322.090.957.137.00.00.00.00.0011.5
38Guglielmo Vicarioit ITAGKEmpoli26-210199626.026.02340.034.0...33.8147.050.343.0521.028.05.416.00.6210.7
39Jeroen Zoetnl NEDGKSpezia32-11919914.03.0244.02.0...37.112.066.746.340.02.05.06.02.2017.2
40Petar Zovkoba BIHGKSpezia21-04120021.00.074.02.0...35.113.076.951.124.01.04.22.02.4717.0
\n", "

41 rows × 47 columns

\n", "
" ], "text/plain": [ " player nationality position team age \\\n", "0 Emil Audero it ITA GK Sampdoria 26-107 \n", "1 Francesco Bardi it ITA GK Bologna 31-107 \n", "2 Marco Carnesecchi it ITA GK Cremonese 22-308 \n", "3 Michele Cerofolini it ITA GK Fiorentina 24-121 \n", "4 Andrea Consigli it ITA GK Sassuolo 36-098 \n", "5 Alessio Cragno it ITA GK Monza 28-311 \n", "6 Michele Di Gregorio it ITA GK Monza 25-282 \n", "7 Bartłomiej Drągowski pl POL GK Spezia 25-259 \n", "8 Wladimiro Falcone it ITA GK Lecce 28-023 \n", "9 Pierluigi Gollini it ITA GK Fiorentina 28-048 \n", "10 Pierluigi Gollini it ITA GK Napoli 28-048 \n", "11 Samir Handanović si SVN GK Inter 38-295 \n", "12 Mike Maignan fr FRA GK Milan 27-306 \n", "13 Federico Marchetti it ITA GK Spezia 40-087 \n", "14 Luís Maximiano pt POR GK Lazio 24-120 \n", "15 Alex Meret it ITA GK Napoli 26-044 \n", "16 Vanja Milinković-Savić rs SRB GK Torino 26-074 \n", "17 Lorenzo Montipò it ITA GK Hellas Verona 27-074 \n", "18 Juan Musso ar ARG GK Atalanta 28-364 \n", "19 Guillermo Ochoa mx MEX GK Salernitana 37-296 \n", "20 André Onana cm CMR GK Inter 27-033 \n", "21 Rui Patrício pt POR GK Roma 35-079 \n", "22 Gianluca Pegolo it ITA GK Sassuolo 42-041 \n", "23 Simone Perilli it ITA GK Hellas Verona 28-118 \n", "24 Mattia Perin it ITA GK Juventus 30-176 \n", "25 Samuele Perisan it ITA GK Empoli 25-257 \n", "26 Ivan Provedel it ITA GK Lazio 29-049 \n", "27 Ionuț Radu ro ROU GK Cremonese 25-342 \n", "28 Nicola Ravaglia it ITA GK Sampdoria 34-144 \n", "29 Luigi Sepe it ITA GK Salernitana 31-362 \n", "30 Marco Silvestri it ITA GK Udinese 32-064 \n", "31 Salvatore Sirigu it ITA GK Fiorentina 36-113 \n", "32 Łukasz Skorupski pl POL GK Bologna 32-000 \n", "33 Marco Sportiello it ITA GK Atalanta 30-360 \n", "34 Wojciech Szczęsny pl POL GK Juventus 33-017 \n", "35 Ciprian Tătărușanu ro ROU GK Milan 37-085 \n", "36 Pietro Terracciano it ITA GK Fiorentina 33-058 \n", "37 Martin Turk si SVN GK Sampdoria 19-257 \n", "38 Guglielmo Vicario it ITA GK Empoli 26-210 \n", "39 Jeroen Zoet nl NED GK Spezia 32-119 \n", "40 Petar Zovko ba BIH GK Spezia 21-041 \n", "\n", " birth_year gk_games gk_games_starts gk_minutes gk_goals_against ... \\\n", "0 1997 25.0 25.0 2250.0 39.0 ... \n", "1 1992 1.0 1.0 90.0 0.0 ... \n", "2 2000 24.0 24.0 2160.0 40.0 ... \n", "3 1999 1.0 1.0 90.0 0.0 ... \n", "4 1987 31.0 31.0 2790.0 46.0 ... \n", "5 1994 1.0 1.0 90.0 3.0 ... \n", "6 1997 32.0 32.0 2880.0 41.0 ... \n", "7 1997 30.0 30.0 2586.0 48.0 ... \n", "8 1995 33.0 33.0 2970.0 40.0 ... \n", "9 1995 3.0 3.0 270.0 2.0 ... \n", "10 1995 1.0 1.0 90.0 0.0 ... \n", "11 1984 12.0 12.0 1080.0 16.0 ... \n", "12 1995 17.0 17.0 1530.0 17.0 ... \n", "13 1983 1.0 0.0 66.0 2.0 ... \n", "14 1999 1.0 1.0 5.0 0.0 ... \n", "15 1997 32.0 32.0 2880.0 23.0 ... \n", "16 1997 33.0 33.0 2970.0 38.0 ... \n", "17 1996 32.0 32.0 2880.0 51.0 ... \n", "18 1994 24.0 24.0 2077.0 27.0 ... \n", "19 1985 16.0 16.0 1440.0 27.0 ... \n", "20 1996 21.0 21.0 1890.0 19.0 ... \n", "21 1988 33.0 33.0 2970.0 31.0 ... \n", "22 1981 2.0 2.0 180.0 3.0 ... \n", "23 1995 1.0 1.0 90.0 0.0 ... \n", "24 1992 10.0 9.0 858.0 7.0 ... \n", "25 1997 7.0 7.0 630.0 9.0 ... \n", "26 1994 33.0 32.0 2963.0 24.0 ... \n", "27 1997 9.0 9.0 810.0 19.0 ... \n", "28 1988 6.0 6.0 540.0 15.0 ... \n", "29 1991 17.0 17.0 1530.0 27.0 ... \n", "30 1991 33.0 33.0 2970.0 41.0 ... \n", "31 1987 1.0 1.0 90.0 0.0 ... \n", "32 1991 32.0 32.0 2880.0 43.0 ... \n", "33 1992 10.0 9.0 893.0 12.0 ... \n", "34 1990 24.0 24.0 2112.0 21.0 ... \n", "35 1986 16.0 16.0 1440.0 22.0 ... \n", "36 1990 28.0 28.0 2520.0 37.0 ... \n", "37 2003 2.0 2.0 180.0 5.0 ... \n", "38 1996 26.0 26.0 2340.0 34.0 ... \n", "39 1991 4.0 3.0 244.0 2.0 ... \n", "40 2002 1.0 0.0 74.0 2.0 ... \n", "\n", " gk_passes_length_avg gk_goal_kicks gk_pct_goal_kicks_launched \\\n", "0 39.1 200.0 57.0 \n", "1 35.6 9.0 44.4 \n", "2 41.4 179.0 65.9 \n", "3 31.1 3.0 100.0 \n", "4 33.8 265.0 31.3 \n", "5 22.6 6.0 16.7 \n", "6 32.6 209.0 37.3 \n", "7 34.1 179.0 60.9 \n", "8 41.7 239.0 76.6 \n", "9 32.4 11.0 63.6 \n", "10 31.7 5.0 0.0 \n", "11 24.7 64.0 7.8 \n", "12 30.8 60.0 33.3 \n", "13 24.3 8.0 37.5 \n", "14 0.0 0.0 0.0 \n", "15 26.3 194.0 20.1 \n", "16 39.6 251.0 91.2 \n", "17 44.3 243.0 69.1 \n", "18 32.1 157.0 62.4 \n", "19 41.9 164.0 68.9 \n", "20 29.9 132.0 32.6 \n", "21 33.5 230.0 37.0 \n", "22 29.7 16.0 31.3 \n", "23 57.3 13.0 100.0 \n", "24 31.1 60.0 41.7 \n", "25 32.7 75.0 34.7 \n", "26 33.1 167.0 36.5 \n", "27 37.3 67.0 50.7 \n", "28 37.6 74.0 51.4 \n", "29 35.9 154.0 48.7 \n", "30 32.7 256.0 36.7 \n", "31 37.7 8.0 50.0 \n", "32 32.5 235.0 37.0 \n", "33 29.7 87.0 73.6 \n", "34 34.0 129.0 48.1 \n", "35 32.9 83.0 51.8 \n", "36 33.5 186.0 45.2 \n", "37 37.3 22.0 90.9 \n", "38 33.8 147.0 50.3 \n", "39 37.1 12.0 66.7 \n", "40 35.1 13.0 76.9 \n", "\n", " gk_goal_kick_length_avg gk_crosses gk_crosses_stopped \\\n", "0 44.2 356.0 24.0 \n", "1 33.4 10.0 0.0 \n", "2 52.8 351.0 28.0 \n", "3 56.3 2.0 0.0 \n", "4 32.8 424.0 26.0 \n", "5 33.3 7.0 0.0 \n", "6 34.7 469.0 13.0 \n", "7 47.3 428.0 13.0 \n", "8 52.3 470.0 22.0 \n", "9 49.3 24.0 1.0 \n", "10 15.4 12.0 1.0 \n", "11 24.4 121.0 2.0 \n", "12 35.1 164.0 12.0 \n", "13 32.4 8.0 0.0 \n", "14 0.0 0.0 0.0 \n", "15 26.8 320.0 11.0 \n", "16 69.7 407.0 27.0 \n", "17 50.3 430.0 25.0 \n", "18 48.6 253.0 14.0 \n", "19 49.0 260.0 8.0 \n", "20 35.9 240.0 14.0 \n", "21 35.1 387.0 15.0 \n", "22 28.3 28.0 2.0 \n", "23 69.8 19.0 1.0 \n", "24 36.5 148.0 4.0 \n", "25 34.3 134.0 5.0 \n", "26 34.9 433.0 18.0 \n", "27 46.3 107.0 6.0 \n", "28 37.7 112.0 6.0 \n", "29 41.1 222.0 16.0 \n", "30 35.2 470.0 12.0 \n", "31 41.8 12.0 0.0 \n", "32 34.7 422.0 24.0 \n", "33 52.4 142.0 14.0 \n", "34 40.6 338.0 9.0 \n", "35 41.8 195.0 9.0 \n", "36 40.2 268.0 12.0 \n", "37 57.1 37.0 0.0 \n", "38 43.0 521.0 28.0 \n", "39 46.3 40.0 2.0 \n", "40 51.1 24.0 1.0 \n", "\n", " gk_crosses_stopped_pct gk_def_actions_outside_pen_area \\\n", "0 6.7 23.0 \n", "1 0.0 0.0 \n", "2 8.0 24.0 \n", "3 0.0 0.0 \n", "4 6.1 26.0 \n", "5 0.0 2.0 \n", "6 2.8 27.0 \n", "7 3.0 32.0 \n", "8 4.7 37.0 \n", "9 4.2 0.0 \n", "10 8.3 0.0 \n", "11 1.7 10.0 \n", "12 7.3 28.0 \n", "13 0.0 1.0 \n", "14 0.0 0.0 \n", "15 3.4 35.0 \n", "16 6.6 66.0 \n", "17 5.8 51.0 \n", "18 5.5 24.0 \n", "19 3.1 7.0 \n", "20 5.8 9.0 \n", "21 3.9 25.0 \n", "22 7.1 0.0 \n", "23 5.3 1.0 \n", "24 2.7 11.0 \n", "25 3.7 4.0 \n", "26 4.2 46.0 \n", "27 5.6 9.0 \n", "28 5.4 1.0 \n", "29 7.2 13.0 \n", "30 2.6 19.0 \n", "31 0.0 2.0 \n", "32 5.7 23.0 \n", "33 9.9 15.0 \n", "34 2.7 19.0 \n", "35 4.6 13.0 \n", "36 4.5 52.0 \n", "37 0.0 0.0 \n", "38 5.4 16.0 \n", "39 5.0 6.0 \n", "40 4.2 2.0 \n", "\n", " gk_def_actions_outside_pen_area_per90 gk_avg_distance_def_actions \n", "0 0.92 13.9 \n", "1 0.00 0.0 \n", "2 1.00 13.9 \n", "3 0.00 5.0 \n", "4 0.84 13.9 \n", "5 2.00 25.7 \n", "6 0.84 13.3 \n", "7 1.11 14.2 \n", "8 1.12 14.1 \n", "9 0.00 9.3 \n", "10 0.00 2.0 \n", "11 0.83 16.2 \n", "12 1.65 18.3 \n", "13 1.36 22.0 \n", "14 0.00 19.0 \n", "15 1.09 16.9 \n", "16 2.00 17.2 \n", "17 1.59 15.5 \n", "18 1.04 15.6 \n", "19 0.44 11.6 \n", "20 0.43 12.5 \n", "21 0.76 13.9 \n", "22 0.00 9.0 \n", "23 1.00 12.0 \n", "24 1.15 15.7 \n", "25 0.57 11.6 \n", "26 1.40 16.0 \n", "27 1.00 14.5 \n", "28 0.17 11.0 \n", "29 0.76 14.2 \n", "30 0.58 12.3 \n", "31 2.00 26.3 \n", "32 0.72 13.2 \n", "33 1.51 16.0 \n", "34 0.81 15.2 \n", "35 0.81 14.4 \n", "36 1.86 18.5 \n", "37 0.00 11.5 \n", "38 0.62 10.7 \n", "39 2.20 17.2 \n", "40 2.47 17.0 \n", "\n", "[41 rows x 47 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_keeper = get_keeper_data('https://fbref.com/en/comps/11/','/Serie-A-Stats')\n", "\n", "df_keeper.to_csv('fbref_data/keepers_players.csv', index=False)\n", "\n", "df_keeper" ] }, { "cell_type": "code", "execution_count": 5, "id": "b9924851", "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", "
teamplayers_usedpossessiongamesgames_startsminutesgoalsassistspens_madepens_att...foulsfouledoffsidespens_wonpens_concededown_goalsball_recoveriesaerials_wonaerials_lostaerials_won_pct
0Atalanta25.049.833.0363.02970.055.035.06.08.0...399.0335.049.06.03.02.01968.0508.0418.054.9
1Bologna27.054.033.0363.02970.041.032.06.06.0...412.0378.069.05.09.03.01836.0325.0397.045.0
2Cremonese32.043.033.0363.02970.029.014.04.06.0...415.0349.064.04.05.01.01817.0500.0660.043.1
3Empoli31.046.733.0363.02970.028.015.01.01.0...379.0390.043.01.06.01.01557.0343.0424.044.7
4Fiorentina30.056.833.0363.02970.043.032.04.06.0...421.0461.045.03.05.02.01798.0539.0458.054.1
5Hellas Verona36.041.733.0363.02970.025.019.01.01.0...476.0337.065.01.01.02.01954.0666.0650.050.6
6Inter24.056.933.0363.02970.058.041.04.05.0...390.0360.061.04.03.02.01723.0465.0369.055.8
7Juventus29.048.733.0363.02970.050.037.03.06.0...383.0354.057.06.04.00.01685.0425.0408.051.0
8Lazio22.051.333.0363.02970.051.032.05.07.0...347.0421.046.05.01.00.01734.0334.0333.050.1
9Lecce29.041.733.0363.02970.026.017.03.04.0...483.0383.063.03.05.03.01843.0499.0624.044.4
10Milan29.054.833.0363.02970.050.040.03.03.0...404.0378.052.01.05.01.01800.0508.0419.054.8
11Monza31.055.033.0363.02970.039.026.05.05.0...433.0433.059.05.01.01.01612.0388.0378.050.7
12Napoli26.062.233.0363.02970.067.052.06.07.0...337.0406.055.05.02.00.01760.0425.0353.054.6
13Roma27.048.633.0363.02970.045.031.06.09.0...392.0439.053.05.03.01.01749.0467.0371.055.7
14Salernitana28.044.233.0363.02970.039.028.02.02.0...408.0369.060.01.010.00.01706.0462.0495.048.3
15Sampdoria37.046.833.0363.02970.020.016.01.02.0...448.0458.048.01.08.02.01671.0554.0569.049.3
16Sassuolo29.049.233.0363.02970.039.025.07.08.0...361.0377.031.06.04.00.01547.0339.0398.046.0
17Spezia34.046.933.0363.02970.026.017.04.04.0...451.0321.046.02.06.02.01803.0448.0498.047.4
18Torino28.053.433.0363.02970.035.028.02.02.0...445.0339.073.02.06.00.01757.0508.0548.048.1
19Udinese27.048.133.0363.02970.042.037.01.02.0...402.0422.047.01.06.02.01680.0421.0354.054.3
\n", "

20 rows × 152 columns

\n", "
" ], "text/plain": [ " team players_used possession games games_starts minutes \\\n", "0 Atalanta 25.0 49.8 33.0 363.0 2970.0 \n", "1 Bologna 27.0 54.0 33.0 363.0 2970.0 \n", "2 Cremonese 32.0 43.0 33.0 363.0 2970.0 \n", "3 Empoli 31.0 46.7 33.0 363.0 2970.0 \n", "4 Fiorentina 30.0 56.8 33.0 363.0 2970.0 \n", "5 Hellas Verona 36.0 41.7 33.0 363.0 2970.0 \n", "6 Inter 24.0 56.9 33.0 363.0 2970.0 \n", "7 Juventus 29.0 48.7 33.0 363.0 2970.0 \n", "8 Lazio 22.0 51.3 33.0 363.0 2970.0 \n", "9 Lecce 29.0 41.7 33.0 363.0 2970.0 \n", "10 Milan 29.0 54.8 33.0 363.0 2970.0 \n", "11 Monza 31.0 55.0 33.0 363.0 2970.0 \n", "12 Napoli 26.0 62.2 33.0 363.0 2970.0 \n", "13 Roma 27.0 48.6 33.0 363.0 2970.0 \n", "14 Salernitana 28.0 44.2 33.0 363.0 2970.0 \n", "15 Sampdoria 37.0 46.8 33.0 363.0 2970.0 \n", "16 Sassuolo 29.0 49.2 33.0 363.0 2970.0 \n", "17 Spezia 34.0 46.9 33.0 363.0 2970.0 \n", "18 Torino 28.0 53.4 33.0 363.0 2970.0 \n", "19 Udinese 27.0 48.1 33.0 363.0 2970.0 \n", "\n", " goals assists pens_made pens_att ... fouls fouled offsides \\\n", "0 55.0 35.0 6.0 8.0 ... 399.0 335.0 49.0 \n", "1 41.0 32.0 6.0 6.0 ... 412.0 378.0 69.0 \n", "2 29.0 14.0 4.0 6.0 ... 415.0 349.0 64.0 \n", "3 28.0 15.0 1.0 1.0 ... 379.0 390.0 43.0 \n", "4 43.0 32.0 4.0 6.0 ... 421.0 461.0 45.0 \n", "5 25.0 19.0 1.0 1.0 ... 476.0 337.0 65.0 \n", "6 58.0 41.0 4.0 5.0 ... 390.0 360.0 61.0 \n", "7 50.0 37.0 3.0 6.0 ... 383.0 354.0 57.0 \n", "8 51.0 32.0 5.0 7.0 ... 347.0 421.0 46.0 \n", "9 26.0 17.0 3.0 4.0 ... 483.0 383.0 63.0 \n", "10 50.0 40.0 3.0 3.0 ... 404.0 378.0 52.0 \n", "11 39.0 26.0 5.0 5.0 ... 433.0 433.0 59.0 \n", "12 67.0 52.0 6.0 7.0 ... 337.0 406.0 55.0 \n", "13 45.0 31.0 6.0 9.0 ... 392.0 439.0 53.0 \n", "14 39.0 28.0 2.0 2.0 ... 408.0 369.0 60.0 \n", "15 20.0 16.0 1.0 2.0 ... 448.0 458.0 48.0 \n", "16 39.0 25.0 7.0 8.0 ... 361.0 377.0 31.0 \n", "17 26.0 17.0 4.0 4.0 ... 451.0 321.0 46.0 \n", "18 35.0 28.0 2.0 2.0 ... 445.0 339.0 73.0 \n", "19 42.0 37.0 1.0 2.0 ... 402.0 422.0 47.0 \n", "\n", " pens_won pens_conceded own_goals ball_recoveries aerials_won \\\n", "0 6.0 3.0 2.0 1968.0 508.0 \n", "1 5.0 9.0 3.0 1836.0 325.0 \n", "2 4.0 5.0 1.0 1817.0 500.0 \n", "3 1.0 6.0 1.0 1557.0 343.0 \n", "4 3.0 5.0 2.0 1798.0 539.0 \n", "5 1.0 1.0 2.0 1954.0 666.0 \n", "6 4.0 3.0 2.0 1723.0 465.0 \n", "7 6.0 4.0 0.0 1685.0 425.0 \n", "8 5.0 1.0 0.0 1734.0 334.0 \n", "9 3.0 5.0 3.0 1843.0 499.0 \n", "10 1.0 5.0 1.0 1800.0 508.0 \n", "11 5.0 1.0 1.0 1612.0 388.0 \n", "12 5.0 2.0 0.0 1760.0 425.0 \n", "13 5.0 3.0 1.0 1749.0 467.0 \n", "14 1.0 10.0 0.0 1706.0 462.0 \n", "15 1.0 8.0 2.0 1671.0 554.0 \n", "16 6.0 4.0 0.0 1547.0 339.0 \n", "17 2.0 6.0 2.0 1803.0 448.0 \n", "18 2.0 6.0 0.0 1757.0 508.0 \n", "19 1.0 6.0 2.0 1680.0 421.0 \n", "\n", " aerials_lost aerials_won_pct \n", "0 418.0 54.9 \n", "1 397.0 45.0 \n", "2 660.0 43.1 \n", "3 424.0 44.7 \n", "4 458.0 54.1 \n", "5 650.0 50.6 \n", "6 369.0 55.8 \n", "7 408.0 51.0 \n", "8 333.0 50.1 \n", "9 624.0 44.4 \n", "10 419.0 54.8 \n", "11 378.0 50.7 \n", "12 353.0 54.6 \n", "13 371.0 55.7 \n", "14 495.0 48.3 \n", "15 569.0 49.3 \n", "16 398.0 46.0 \n", "17 498.0 47.4 \n", "18 548.0 48.1 \n", "19 354.0 54.3 \n", "\n", "[20 rows x 152 columns]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_team = get_team_data('https://fbref.com/en/comps/11/','/Serie-A-Stats', 'for')\n", "\n", "df_team.to_csv('fbref_data/teams.csv', index=False)\n", "\n", "df_team" ] }, { "cell_type": "code", "execution_count": 6, "id": "5868ec4a", "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", "
teamplayers_usedpossessiongamesgames_startsminutesgoalsassistspens_madepens_att...foulsfouledoffsidespens_wonpens_concededown_goalsball_recoveriesaerials_wonaerials_lostaerials_won_pct
0vs Atalanta25.050.233.0363.02970.037.028.03.03.0...354.0372.042.01.08.01.01976.0418.0508.045.1
1vs Bologna27.046.033.0363.02970.040.024.07.09.0...400.0388.054.06.06.01.01775.0397.0325.055.0
2vs Cremonese32.057.033.0363.02970.058.039.05.05.0...373.0393.057.04.06.00.01867.0660.0500.056.9
3vs Empoli31.053.333.0363.02970.042.028.04.06.0...412.0365.067.04.01.01.01693.0424.0343.055.3
4vs Fiorentina30.043.233.0363.02970.037.026.05.05.0...487.0400.080.03.06.02.01708.0458.0539.045.9
5vs Hellas Verona36.058.333.0363.02970.049.043.00.01.0...358.0455.035.01.01.02.01833.0650.0666.049.4
6vs Inter24.043.133.0363.02970.033.028.03.03.0...386.0359.031.03.05.02.01532.0369.0465.044.2
7vs Juventus29.051.333.0363.02970.028.022.03.04.0...370.0345.047.01.06.00.01662.0408.0425.049.0
8vs Lazio22.048.733.0363.02970.024.016.01.01.0...447.0330.058.01.07.01.01788.0333.0334.049.9
9vs Lecce29.058.333.0363.02970.037.025.05.05.0...401.0455.061.04.04.02.01782.0624.0499.055.6
10vs Milan29.045.233.0363.02970.038.030.04.05.0...399.0387.035.05.03.03.01732.0419.0508.045.2
11vs Monza31.045.033.0363.02970.043.027.01.01.0...462.0414.050.01.05.02.01719.0378.0388.049.3
12vs Napoli26.037.833.0363.02970.023.015.01.02.0...431.0313.041.01.06.02.01651.0353.0425.045.4
13vs Roma27.051.433.0363.02970.030.020.02.03.0...466.0366.021.02.09.00.01741.0371.0467.044.3
14vs Salernitana28.055.833.0363.02970.054.035.06.010.0...403.0384.065.010.02.02.01817.0495.0462.051.7
15vs Sampdoria37.053.233.0363.02970.057.043.06.09.0...475.0427.081.06.02.00.01802.0569.0554.050.7
16vs Sassuolo29.050.833.0363.02970.049.037.04.04.0...407.0332.0100.02.08.01.01710.0398.0339.054.0
17vs Spezia34.053.133.0363.02970.052.036.04.06.0...345.0414.070.04.04.02.01820.0498.0448.052.6
18vs Torino28.046.633.0363.02970.038.025.05.06.0...364.0427.035.04.02.00.01709.0548.0508.051.9
19vs Udinese27.051.933.0363.02970.039.027.05.06.0...446.0384.056.04.02.01.01683.0354.0421.045.7
\n", "

20 rows × 152 columns

\n", "
" ], "text/plain": [ " team players_used possession games games_starts minutes \\\n", "0 vs Atalanta 25.0 50.2 33.0 363.0 2970.0 \n", "1 vs Bologna 27.0 46.0 33.0 363.0 2970.0 \n", "2 vs Cremonese 32.0 57.0 33.0 363.0 2970.0 \n", "3 vs Empoli 31.0 53.3 33.0 363.0 2970.0 \n", "4 vs Fiorentina 30.0 43.2 33.0 363.0 2970.0 \n", "5 vs Hellas Verona 36.0 58.3 33.0 363.0 2970.0 \n", "6 vs Inter 24.0 43.1 33.0 363.0 2970.0 \n", "7 vs Juventus 29.0 51.3 33.0 363.0 2970.0 \n", "8 vs Lazio 22.0 48.7 33.0 363.0 2970.0 \n", "9 vs Lecce 29.0 58.3 33.0 363.0 2970.0 \n", "10 vs Milan 29.0 45.2 33.0 363.0 2970.0 \n", "11 vs Monza 31.0 45.0 33.0 363.0 2970.0 \n", "12 vs Napoli 26.0 37.8 33.0 363.0 2970.0 \n", "13 vs Roma 27.0 51.4 33.0 363.0 2970.0 \n", "14 vs Salernitana 28.0 55.8 33.0 363.0 2970.0 \n", "15 vs Sampdoria 37.0 53.2 33.0 363.0 2970.0 \n", "16 vs Sassuolo 29.0 50.8 33.0 363.0 2970.0 \n", "17 vs Spezia 34.0 53.1 33.0 363.0 2970.0 \n", "18 vs Torino 28.0 46.6 33.0 363.0 2970.0 \n", "19 vs Udinese 27.0 51.9 33.0 363.0 2970.0 \n", "\n", " goals assists pens_made pens_att ... fouls fouled offsides \\\n", "0 37.0 28.0 3.0 3.0 ... 354.0 372.0 42.0 \n", "1 40.0 24.0 7.0 9.0 ... 400.0 388.0 54.0 \n", "2 58.0 39.0 5.0 5.0 ... 373.0 393.0 57.0 \n", "3 42.0 28.0 4.0 6.0 ... 412.0 365.0 67.0 \n", "4 37.0 26.0 5.0 5.0 ... 487.0 400.0 80.0 \n", "5 49.0 43.0 0.0 1.0 ... 358.0 455.0 35.0 \n", "6 33.0 28.0 3.0 3.0 ... 386.0 359.0 31.0 \n", "7 28.0 22.0 3.0 4.0 ... 370.0 345.0 47.0 \n", "8 24.0 16.0 1.0 1.0 ... 447.0 330.0 58.0 \n", "9 37.0 25.0 5.0 5.0 ... 401.0 455.0 61.0 \n", "10 38.0 30.0 4.0 5.0 ... 399.0 387.0 35.0 \n", "11 43.0 27.0 1.0 1.0 ... 462.0 414.0 50.0 \n", "12 23.0 15.0 1.0 2.0 ... 431.0 313.0 41.0 \n", "13 30.0 20.0 2.0 3.0 ... 466.0 366.0 21.0 \n", "14 54.0 35.0 6.0 10.0 ... 403.0 384.0 65.0 \n", "15 57.0 43.0 6.0 9.0 ... 475.0 427.0 81.0 \n", "16 49.0 37.0 4.0 4.0 ... 407.0 332.0 100.0 \n", "17 52.0 36.0 4.0 6.0 ... 345.0 414.0 70.0 \n", "18 38.0 25.0 5.0 6.0 ... 364.0 427.0 35.0 \n", "19 39.0 27.0 5.0 6.0 ... 446.0 384.0 56.0 \n", "\n", " pens_won pens_conceded own_goals ball_recoveries aerials_won \\\n", "0 1.0 8.0 1.0 1976.0 418.0 \n", "1 6.0 6.0 1.0 1775.0 397.0 \n", "2 4.0 6.0 0.0 1867.0 660.0 \n", "3 4.0 1.0 1.0 1693.0 424.0 \n", "4 3.0 6.0 2.0 1708.0 458.0 \n", "5 1.0 1.0 2.0 1833.0 650.0 \n", "6 3.0 5.0 2.0 1532.0 369.0 \n", "7 1.0 6.0 0.0 1662.0 408.0 \n", "8 1.0 7.0 1.0 1788.0 333.0 \n", "9 4.0 4.0 2.0 1782.0 624.0 \n", "10 5.0 3.0 3.0 1732.0 419.0 \n", "11 1.0 5.0 2.0 1719.0 378.0 \n", "12 1.0 6.0 2.0 1651.0 353.0 \n", "13 2.0 9.0 0.0 1741.0 371.0 \n", "14 10.0 2.0 2.0 1817.0 495.0 \n", "15 6.0 2.0 0.0 1802.0 569.0 \n", "16 2.0 8.0 1.0 1710.0 398.0 \n", "17 4.0 4.0 2.0 1820.0 498.0 \n", "18 4.0 2.0 0.0 1709.0 548.0 \n", "19 4.0 2.0 1.0 1683.0 354.0 \n", "\n", " aerials_lost aerials_won_pct \n", "0 508.0 45.1 \n", "1 325.0 55.0 \n", "2 500.0 56.9 \n", "3 343.0 55.3 \n", "4 539.0 45.9 \n", "5 666.0 49.4 \n", "6 465.0 44.2 \n", "7 425.0 49.0 \n", "8 334.0 49.9 \n", "9 499.0 55.6 \n", "10 508.0 45.2 \n", "11 388.0 49.3 \n", "12 425.0 45.4 \n", "13 467.0 44.3 \n", "14 462.0 51.7 \n", "15 554.0 50.7 \n", "16 339.0 54.0 \n", "17 448.0 52.6 \n", "18 508.0 51.9 \n", "19 421.0 45.7 \n", "\n", "[20 rows x 152 columns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_vsteam = get_team_data('https://fbref.com/en/comps/11/','/Serie-A-Stats', 'vs')\n", "\n", "df_vsteam.to_csv('fbref_data/teams_vs.csv', index=False)\n", "\n", "df_vsteam" ] }, { "cell_type": "code", "execution_count": 7, "id": "11e51337", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Outfield player columns\n", "['player' 'nationality' 'position' 'team' 'age' 'birth_year' 'games'\n", " 'games_starts' 'minutes' 'goals' 'assists' 'pens_made' 'pens_att'\n", " 'cards_yellow' 'cards_red' 'goals_per90' 'assists_per90'\n", " 'goals_assists_per90' 'goals_pens_per90' 'goals_assists_pens_per90' 'xg'\n", " 'npxg' 'xg_per90' 'npxg_per90' 'minutes_90s' 'shots_on_target'\n", " 'shots_free_kicks' 'shots_on_target_pct' 'shots_on_target_per90'\n", " 'goals_per_shot' 'goals_per_shot_on_target' 'npxg_per_shot' 'xg_net'\n", " 'npxg_net' 'passes_completed' 'passes' 'passes_pct'\n", " 'passes_total_distance' 'passes_progressive_distance'\n", " 'passes_completed_short' 'passes_short' 'passes_pct_short'\n", " 'passes_completed_medium' 'passes_medium' 'passes_pct_medium'\n", " 'passes_completed_long' 'passes_long' 'passes_pct_long' 'assisted_shots'\n", " 'passes_into_final_third' 'passes_into_penalty_area'\n", " 'crosses_into_penalty_area' 'progressive_passes' 'passes_live'\n", " 'passes_dead' 'passes_free_kicks' 'through_balls' 'passes_switches'\n", " 'crosses' 'corner_kicks' 'corner_kicks_in' 'corner_kicks_out'\n", " 'corner_kicks_straight' 'throw_ins' 'passes_offsides' 'passes_blocked'\n", " 'sca' 'sca_per90' 'sca_passes_live' 'sca_passes_dead' 'sca_shots'\n", " 'sca_fouled' 'gca' 'gca_per90' 'gca_passes_live' 'gca_passes_dead'\n", " 'gca_shots' 'gca_fouled' 'gca_defense' 'tackles' 'tackles_won'\n", " 'tackles_def_3rd' 'tackles_mid_3rd' 'tackles_att_3rd' 'blocks'\n", " 'blocked_shots' 'blocked_passes' 'interceptions' 'clearances' 'errors'\n", " 'touches' 'touches_def_pen_area' 'touches_def_3rd' 'touches_mid_3rd'\n", " 'touches_att_3rd' 'touches_att_pen_area' 'touches_live_ball' 'carries'\n", " 'progressive_carries' 'carries_into_final_third'\n", " 'carries_into_penalty_area' 'passes_received' 'miscontrols'\n", " 'dispossessed' 'cards_yellow_red' 'fouls' 'fouled' 'offsides' 'pens_won'\n", " 'pens_conceded' 'own_goals' 'ball_recoveries' 'aerials_won'\n", " 'aerials_lost' 'aerials_won_pct']\n", "Keeper player columns\n", "['player' 'nationality' 'position' 'team' 'age' 'birth_year' 'gk_games'\n", " 'gk_games_starts' 'gk_minutes' 'gk_goals_against'\n", " 'gk_goals_against_per90' 'gk_shots_on_target_against' 'gk_saves'\n", " 'gk_save_pct' 'gk_wins' 'gk_ties' 'gk_losses' 'gk_clean_sheets'\n", " 'gk_clean_sheets_pct' 'gk_pens_att' 'gk_pens_allowed' 'gk_pens_saved'\n", " 'gk_pens_missed' 'minutes_90s' 'gk_free_kick_goals_against'\n", " 'gk_corner_kick_goals_against' 'gk_own_goals_against' 'gk_psxg'\n", " 'gk_psnpxg_per_shot_on_target_against' 'gk_psxg_net' 'gk_psxg_net_per90'\n", " 'gk_passes_completed_launched' 'gk_passes_launched'\n", " 'gk_passes_pct_launched' 'gk_passes' 'gk_passes_throws'\n", " 'gk_pct_passes_launched' 'gk_passes_length_avg' 'gk_goal_kicks'\n", " 'gk_pct_goal_kicks_launched' 'gk_goal_kick_length_avg' 'gk_crosses'\n", " 'gk_crosses_stopped' 'gk_crosses_stopped_pct'\n", " 'gk_def_actions_outside_pen_area' 'gk_def_actions_outside_pen_area_per90'\n", " 'gk_avg_distance_def_actions']\n", "Team columns\n", "['team' 'players_used' 'possession' 'games' 'games_starts' 'minutes'\n", " 'goals' 'assists' 'pens_made' 'pens_att' 'cards_yellow' 'cards_red'\n", " 'goals_per90' 'assists_per90' 'goals_assists_per90' 'goals_pens_per90'\n", " 'goals_assists_pens_per90' 'xg' 'npxg' 'xg_per90' 'npxg_per90' 'gk_games'\n", " 'gk_games_starts' 'gk_minutes' 'gk_goals_against'\n", " 'gk_goals_against_per90' 'gk_shots_on_target_against' 'gk_saves'\n", " 'gk_save_pct' 'gk_wins' 'gk_ties' 'gk_losses' 'gk_clean_sheets'\n", " 'gk_clean_sheets_pct' 'gk_pens_att' 'gk_pens_allowed' 'gk_pens_saved'\n", " 'gk_pens_missed' 'minutes_90s' 'gk_free_kick_goals_against'\n", " 'gk_corner_kick_goals_against' 'gk_own_goals_against' 'gk_psxg'\n", " 'gk_psnpxg_per_shot_on_target_against' 'gk_psxg_net' 'gk_psxg_net_per90'\n", " 'gk_passes_completed_launched' 'gk_passes_launched'\n", " 'gk_passes_pct_launched' 'gk_passes' 'gk_passes_throws'\n", " 'gk_pct_passes_launched' 'gk_passes_length_avg' 'gk_goal_kicks'\n", " 'gk_pct_goal_kicks_launched' 'gk_goal_kick_length_avg' 'gk_crosses'\n", " 'gk_crosses_stopped' 'gk_crosses_stopped_pct'\n", " 'gk_def_actions_outside_pen_area' 'gk_def_actions_outside_pen_area_per90'\n", " 'gk_avg_distance_def_actions' 'shots_on_target' 'shots_free_kicks'\n", " 'shots_on_target_pct' 'shots_on_target_per90' 'goals_per_shot'\n", " 'goals_per_shot_on_target' 'npxg_per_shot' 'xg_net' 'npxg_net'\n", " 'passes_completed' 'passes' 'passes_pct' 'passes_total_distance'\n", " 'passes_progressive_distance' 'passes_completed_short' 'passes_short'\n", " 'passes_pct_short' 'passes_completed_medium' 'passes_medium'\n", " 'passes_pct_medium' 'passes_completed_long' 'passes_long'\n", " 'passes_pct_long' 'assisted_shots' 'passes_into_final_third'\n", " 'passes_into_penalty_area' 'crosses_into_penalty_area'\n", " 'progressive_passes' 'passes_live' 'passes_dead' 'passes_free_kicks'\n", " 'through_balls' 'passes_switches' 'crosses' 'corner_kicks'\n", " 'corner_kicks_in' 'corner_kicks_out' 'corner_kicks_straight' 'throw_ins'\n", " 'passes_offsides' 'passes_blocked' 'sca' 'sca_per90' 'sca_passes_live'\n", " 'sca_passes_dead' 'sca_shots' 'sca_fouled' 'gca' 'gca_per90'\n", " 'gca_passes_live' 'gca_passes_dead' 'gca_shots' 'gca_fouled'\n", " 'gca_defense' 'tackles' 'tackles_won' 'tackles_def_3rd' 'tackles_mid_3rd'\n", " 'tackles_att_3rd' 'blocks' 'blocked_shots' 'blocked_passes'\n", " 'interceptions' 'clearances' 'errors' 'touches' 'touches_def_pen_area'\n", " 'touches_def_3rd' 'touches_mid_3rd' 'touches_att_3rd'\n", " 'touches_att_pen_area' 'touches_live_ball' 'carries'\n", " 'progressive_carries' 'carries_into_final_third'\n", " 'carries_into_penalty_area' 'passes_received' 'miscontrols'\n", " 'dispossessed' 'cards_yellow_red' 'fouls' 'fouled' 'offsides' 'pens_won'\n", " 'pens_conceded' 'own_goals' 'ball_recoveries' 'aerials_won'\n", " 'aerials_lost' 'aerials_won_pct']\n", "Vs Team columns\n", "['team' 'players_used' 'possession' 'games' 'games_starts' 'minutes'\n", " 'goals' 'assists' 'pens_made' 'pens_att' 'cards_yellow' 'cards_red'\n", " 'goals_per90' 'assists_per90' 'goals_assists_per90' 'goals_pens_per90'\n", " 'goals_assists_pens_per90' 'xg' 'npxg' 'xg_per90' 'npxg_per90' 'gk_games'\n", " 'gk_games_starts' 'gk_minutes' 'gk_goals_against'\n", " 'gk_goals_against_per90' 'gk_shots_on_target_against' 'gk_saves'\n", " 'gk_save_pct' 'gk_wins' 'gk_ties' 'gk_losses' 'gk_clean_sheets'\n", " 'gk_clean_sheets_pct' 'gk_pens_att' 'gk_pens_allowed' 'gk_pens_saved'\n", " 'gk_pens_missed' 'minutes_90s' 'gk_free_kick_goals_against'\n", " 'gk_corner_kick_goals_against' 'gk_own_goals_against' 'gk_psxg'\n", " 'gk_psnpxg_per_shot_on_target_against' 'gk_psxg_net' 'gk_psxg_net_per90'\n", " 'gk_passes_completed_launched' 'gk_passes_launched'\n", " 'gk_passes_pct_launched' 'gk_passes' 'gk_passes_throws'\n", " 'gk_pct_passes_launched' 'gk_passes_length_avg' 'gk_goal_kicks'\n", " 'gk_pct_goal_kicks_launched' 'gk_goal_kick_length_avg' 'gk_crosses'\n", " 'gk_crosses_stopped' 'gk_crosses_stopped_pct'\n", " 'gk_def_actions_outside_pen_area' 'gk_def_actions_outside_pen_area_per90'\n", " 'gk_avg_distance_def_actions' 'shots_on_target' 'shots_free_kicks'\n", " 'shots_on_target_pct' 'shots_on_target_per90' 'goals_per_shot'\n", " 'goals_per_shot_on_target' 'npxg_per_shot' 'xg_net' 'npxg_net'\n", " 'passes_completed' 'passes' 'passes_pct' 'passes_total_distance'\n", " 'passes_progressive_distance' 'passes_completed_short' 'passes_short'\n", " 'passes_pct_short' 'passes_completed_medium' 'passes_medium'\n", " 'passes_pct_medium' 'passes_completed_long' 'passes_long'\n", " 'passes_pct_long' 'assisted_shots' 'passes_into_final_third'\n", " 'passes_into_penalty_area' 'crosses_into_penalty_area'\n", " 'progressive_passes' 'passes_live' 'passes_dead' 'passes_free_kicks'\n", " 'through_balls' 'passes_switches' 'crosses' 'corner_kicks'\n", " 'corner_kicks_in' 'corner_kicks_out' 'corner_kicks_straight' 'throw_ins'\n", " 'passes_offsides' 'passes_blocked' 'sca' 'sca_per90' 'sca_passes_live'\n", " 'sca_passes_dead' 'sca_shots' 'sca_fouled' 'gca' 'gca_per90'\n", " 'gca_passes_live' 'gca_passes_dead' 'gca_shots' 'gca_fouled'\n", " 'gca_defense' 'tackles' 'tackles_won' 'tackles_def_3rd' 'tackles_mid_3rd'\n", " 'tackles_att_3rd' 'blocks' 'blocked_shots' 'blocked_passes'\n", " 'interceptions' 'clearances' 'errors' 'touches' 'touches_def_pen_area'\n", " 'touches_def_3rd' 'touches_mid_3rd' 'touches_att_3rd'\n", " 'touches_att_pen_area' 'touches_live_ball' 'carries'\n", " 'progressive_carries' 'carries_into_final_third'\n", " 'carries_into_penalty_area' 'passes_received' 'miscontrols'\n", " 'dispossessed' 'cards_yellow_red' 'fouls' 'fouled' 'offsides' 'pens_won'\n", " 'pens_conceded' 'own_goals' 'ball_recoveries' 'aerials_won'\n", " 'aerials_lost' 'aerials_won_pct']\n" ] } ], "source": [ "print('Outfield player columns')\n", "print(df_outfield.columns.values)\n", "\n", "print('Keeper player columns')\n", "print(df_keeper.columns.values)\n", "\n", "print('Team columns')\n", "print(df_team.columns.values)\n", "\n", "print('Vs Team columns')\n", "print(df_team.columns.values)" ] }, { "cell_type": "markdown", "id": "e4f13ae2", "metadata": {}, "source": [ "Scrape data for past seasons. \n", "\n", "Do not repeat if data is already present." ] }, { "cell_type": "code", "execution_count": 8, "id": "2e1370cd", "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", "
playernationalitypositionteamagebirth_yeargamesgames_startsminutesgoals...foulsfouledoffsidespens_wonpens_concededown_goalsball_recoveriesaerials_wonaerials_lostaerials_won_pct
0Tammy Abrahameng ENGFWRoma23199737.036.03084.017.0...38.049.017.01.01.00.068.078.080.049.4
1Francesco Acerbiit ITADFLazio33198830.029.02536.04.0...18.016.04.01.00.00.0162.069.043.061.6
2Michel Aebischerch SUIMFBologna24199712.04.0443.00.0...13.04.00.00.00.00.027.05.04.055.6
3Felix Afena-Gyangh GHAFW,MFRoma18200317.06.0668.02.0...15.024.04.00.00.00.031.011.015.042.3
4Kevin Agudeloco COLMF,FWSpezia22199823.012.01237.03.0...36.024.00.00.00.00.067.015.014.051.7
..................................................................
627Nadir Zorteait ITADF,MFSalernitana22199929.013.01410.01.0...14.06.00.00.00.00.072.08.017.032.0
628Petar Zovkoba BIHGKSpezia1920021.00.029.00.0...0.01.00.00.00.00.00.00.00.00.0
629Szymon Żurkowskipl POLMFEmpoli23199735.029.02307.06.0...41.067.00.00.01.00.0162.024.032.042.9
630Milan Đurićba BIHFWSalernitana31199033.023.02165.05.0...24.045.06.01.00.00.040.0242.083.074.5
631Filip Đuričićrs SRBMF,FWSassuolo29199212.09.0671.02.0...10.014.02.00.00.00.034.03.05.037.5
\n", "

632 rows × 115 columns

\n", "
" ], "text/plain": [ " player nationality position team age birth_year games \\\n", "0 Tammy Abraham eng ENG FW Roma 23 1997 37.0 \n", "1 Francesco Acerbi it ITA DF Lazio 33 1988 30.0 \n", "2 Michel Aebischer ch SUI MF Bologna 24 1997 12.0 \n", "3 Felix Afena-Gyan gh GHA FW,MF Roma 18 2003 17.0 \n", "4 Kevin Agudelo co COL MF,FW Spezia 22 1998 23.0 \n", ".. ... ... ... ... .. ... ... \n", "627 Nadir Zortea it ITA DF,MF Salernitana 22 1999 29.0 \n", "628 Petar Zovko ba BIH GK Spezia 19 2002 1.0 \n", "629 Szymon Żurkowski pl POL MF Empoli 23 1997 35.0 \n", "630 Milan Đurić ba BIH FW Salernitana 31 1990 33.0 \n", "631 Filip Đuričić rs SRB MF,FW Sassuolo 29 1992 12.0 \n", "\n", " games_starts minutes goals ... fouls fouled offsides pens_won \\\n", "0 36.0 3084.0 17.0 ... 38.0 49.0 17.0 1.0 \n", "1 29.0 2536.0 4.0 ... 18.0 16.0 4.0 1.0 \n", "2 4.0 443.0 0.0 ... 13.0 4.0 0.0 0.0 \n", "3 6.0 668.0 2.0 ... 15.0 24.0 4.0 0.0 \n", "4 12.0 1237.0 3.0 ... 36.0 24.0 0.0 0.0 \n", ".. ... ... ... ... ... ... ... ... \n", "627 13.0 1410.0 1.0 ... 14.0 6.0 0.0 0.0 \n", "628 0.0 29.0 0.0 ... 0.0 1.0 0.0 0.0 \n", "629 29.0 2307.0 6.0 ... 41.0 67.0 0.0 0.0 \n", "630 23.0 2165.0 5.0 ... 24.0 45.0 6.0 1.0 \n", "631 9.0 671.0 2.0 ... 10.0 14.0 2.0 0.0 \n", "\n", " pens_conceded own_goals ball_recoveries aerials_won aerials_lost \\\n", "0 1.0 0.0 68.0 78.0 80.0 \n", "1 0.0 0.0 162.0 69.0 43.0 \n", "2 0.0 0.0 27.0 5.0 4.0 \n", "3 0.0 0.0 31.0 11.0 15.0 \n", "4 0.0 0.0 67.0 15.0 14.0 \n", ".. ... ... ... ... ... \n", "627 0.0 0.0 72.0 8.0 17.0 \n", "628 0.0 0.0 0.0 0.0 0.0 \n", "629 1.0 0.0 162.0 24.0 32.0 \n", "630 0.0 0.0 40.0 242.0 83.0 \n", "631 0.0 0.0 34.0 3.0 5.0 \n", "\n", " aerials_won_pct \n", "0 49.4 \n", "1 61.6 \n", "2 55.6 \n", "3 42.3 \n", "4 51.7 \n", ".. ... \n", "627 32.0 \n", "628 0.0 \n", "629 42.9 \n", "630 74.5 \n", "631 37.5 \n", "\n", "[632 rows x 115 columns]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_outfield = get_outfield_data('https://fbref.com/en/comps/11/2021-2022/','/2021-2022-Serie-A-Stats')\n", "\n", "df_outfield.to_csv('fbref_data/season2122/outfield_players.csv', index=False)\n", "\n", "df_outfield" ] }, { "cell_type": "code", "execution_count": null, "id": "36441b0e", "metadata": {}, "outputs": [], "source": [ "df_keeper = get_keeper_data('https://fbref.com/en/comps/11/2021-2022/','/2021-2022-Serie-A-Stats')\n", "\n", "df_keeper.to_csv('fbref_data/season2122/keepers_players.csv', index=False)\n", "\n", "df_keeper" ] }, { "cell_type": "code", "execution_count": null, "id": "9172edae", "metadata": {}, "outputs": [], "source": [ "df_team = get_team_data('https://fbref.com/en/comps/11/2021-2022/','/2021-2022-Serie-A-Stats', 'for')\n", "\n", "df_team.to_csv('fbref_data/season2122/teams.csv', index=False)\n", "\n", "df_team" ] }, { "cell_type": "code", "execution_count": null, "id": "fa6258db", "metadata": {}, "outputs": [], "source": [ "df_vsteam = get_team_data('https://fbref.com/en/comps/11/2021-2022/','/2021-2022-Serie-A-Stats', 'vs')\n", "\n", "df_vsteam.to_csv('fbref_data/season2122/teams_vs.csv', index=False)\n", "\n", "df_vsteam" ] }, { "cell_type": "code", "execution_count": null, "id": "22ad9be5", "metadata": {}, "outputs": [], "source": [ "df_outfield = get_outfield_data('https://fbref.com/en/comps/11/2020-2021/','/2020-2021-Serie-A-Stats')\n", "df_outfield.to_csv('fbref_data/season2021/outfield_players.csv', index=False)\n", "\n", "df_keeper = get_keeper_data('https://fbref.com/en/comps/11/2020-2021/','/2020-2021-Serie-A-Stats')\n", "df_keeper.to_csv('fbref_data/season2021/keepers_players.csv', index=False)\n", "\n", "df_team = get_team_data('https://fbref.com/en/comps/11/2020-2021/','/2020-2021-Serie-A-Stats', 'for')\n", "df_team.to_csv('fbref_data/season2021/teams.csv', index=False)\n", "\n", "df_vsteam = get_team_data('https://fbref.com/en/comps/11/2020-2021/','/2020-2021-Serie-A-Stats', 'vs')\n", "df_vsteam.to_csv('fbref_data/season2021/teams_vs.csv', index=False)\n" ] }, { "cell_type": "code", "execution_count": null, "id": "125223ae", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.13" } }, "nbformat": 4, "nbformat_minor": 5 }