{ "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", " 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", " \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
0Tammy Abrahameng ENGFWRoma25-118199719.015.01338.05.0...19.029.08.01.00.00.028.035.032.052.2
1Francesco Acerbiit ITADFInter34-352198812.010.0930.00.0...7.07.01.00.00.00.052.025.018.058.1
2Yacine Adlifr FRAMF,FWMilan22-18320004.01.0116.00.0...3.01.00.00.00.00.05.00.03.00.0
3Michel Aebischerch SUIFW,MFBologna26-022199717.08.0767.01.0...10.014.05.01.01.00.042.05.08.038.5
4Felix Afena-Gyangh GHAFW,MFCremonese20-009200310.02.0296.00.0...7.03.04.00.00.00.014.08.014.036.4
..................................................................
514Petar Zovkoba BIHGKSpezia20-30920021.00.074.00.0...0.00.00.00.00.00.02.00.00.00.0
515Szymon Żurkowskipl POLMFFiorentina25-12519972.00.032.00.0...1.00.00.00.00.00.02.01.01.050.0
516Szymon Żurkowskipl POLMFSpezia25-12519971.00.08.00.0...0.00.00.00.00.00.03.00.00.00.0
517Milan Đurićba BIHFWHellas Verona32-251199015.06.0618.01.0...15.013.02.00.00.00.014.0103.027.079.2
518Filip Đuričićrs SRBMF,FWSampdoria30-363199218.015.01201.02.0...19.032.00.00.00.00.067.07.011.038.9
\n", "

519 rows × 120 columns

\n", "
" ], "text/plain": [ " player nationality position team age birth_year \\\n", "0 Tammy Abraham eng ENG FW Roma 25-118 1997 \n", "1 Francesco Acerbi it ITA DF Inter 34-352 1988 \n", "2 Yacine Adli fr FRA MF,FW Milan 22-183 2000 \n", "3 Michel Aebischer ch SUI FW,MF Bologna 26-022 1997 \n", "4 Felix Afena-Gyan gh GHA FW,MF Cremonese 20-009 2003 \n", ".. ... ... ... ... ... ... \n", "514 Petar Zovko ba BIH GK Spezia 20-309 2002 \n", "515 Szymon Żurkowski pl POL MF Fiorentina 25-125 1997 \n", "516 Szymon Żurkowski pl POL MF Spezia 25-125 1997 \n", "517 Milan Đurić ba BIH FW Hellas Verona 32-251 1990 \n", "518 Filip Đuričić rs SRB MF,FW Sampdoria 30-363 1992 \n", "\n", " games games_starts minutes goals ... fouls fouled offsides \\\n", "0 19.0 15.0 1338.0 5.0 ... 19.0 29.0 8.0 \n", "1 12.0 10.0 930.0 0.0 ... 7.0 7.0 1.0 \n", "2 4.0 1.0 116.0 0.0 ... 3.0 1.0 0.0 \n", "3 17.0 8.0 767.0 1.0 ... 10.0 14.0 5.0 \n", "4 10.0 2.0 296.0 0.0 ... 7.0 3.0 4.0 \n", ".. ... ... ... ... ... ... ... ... \n", "514 1.0 0.0 74.0 0.0 ... 0.0 0.0 0.0 \n", "515 2.0 0.0 32.0 0.0 ... 1.0 0.0 0.0 \n", "516 1.0 0.0 8.0 0.0 ... 0.0 0.0 0.0 \n", "517 15.0 6.0 618.0 1.0 ... 15.0 13.0 2.0 \n", "518 18.0 15.0 1201.0 2.0 ... 19.0 32.0 0.0 \n", "\n", " pens_won pens_conceded own_goals ball_recoveries aerials_won \\\n", "0 1.0 0.0 0.0 28.0 35.0 \n", "1 0.0 0.0 0.0 52.0 25.0 \n", "2 0.0 0.0 0.0 5.0 0.0 \n", "3 1.0 1.0 0.0 42.0 5.0 \n", "4 0.0 0.0 0.0 14.0 8.0 \n", ".. ... ... ... ... ... \n", "514 0.0 0.0 0.0 2.0 0.0 \n", "515 0.0 0.0 0.0 2.0 1.0 \n", "516 0.0 0.0 0.0 3.0 0.0 \n", "517 0.0 0.0 0.0 14.0 103.0 \n", "518 0.0 0.0 0.0 67.0 7.0 \n", "\n", " aerials_lost aerials_won_pct \n", "0 32.0 52.2 \n", "1 18.0 58.1 \n", "2 3.0 0.0 \n", "3 8.0 38.5 \n", "4 14.0 36.4 \n", ".. ... ... \n", "514 0.0 0.0 \n", "515 1.0 50.0 \n", "516 0.0 0.0 \n", "517 27.0 79.2 \n", "518 11.0 38.9 \n", "\n", "[519 rows x 120 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", "
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-010199719.019.01710.032.0...38.8142.057.744.5243.015.06.220.01.0515.4
1Marco Carnesecchiit ITAGKCremonese22-211200010.010.0900.014.0...40.066.059.149.3108.010.09.37.00.7013.0
2Andrea Consigliit ITAGKSassuolo36-001198717.017.01530.026.0...34.4157.031.833.3220.013.05.915.00.8814.5
3Michele Di Gregorioit ITAGKMonza25-185199719.019.01710.028.0...33.0115.031.331.3246.010.04.112.00.6313.4
4Bartłomiej Drągowskipl POLGKSpezia25-162199718.018.01572.029.0...34.4106.063.247.9235.09.03.824.01.3715.6
5Wladimiro Falconeit ITAGKLecce27-291199520.020.01800.024.0...40.9156.075.051.4304.013.04.320.01.0012.5
6Pierluigi Golliniit ITAGKFiorentina27-31619953.03.0270.02.0...32.411.063.649.324.01.04.20.00.009.3
7Samir Handanovićsi SVNGKInter38-19819848.08.0720.013.0...26.145.04.424.079.02.02.55.00.6314.6
8Mike Maignanfr FRAGKMilan27-20919957.07.0630.08.0...33.518.038.940.465.05.07.76.00.8612.9
9Luís Maximianopt PORGKLazio24-02319991.01.05.00.0...0.00.00.00.00.00.00.00.00.0019.0
10Alex Meretit ITAGKNapoli25-312199719.019.01710.014.0...26.6114.020.227.1197.06.03.023.01.2117.2
11Vanja Milinković-Savićrs SRBGKTorino25-342199719.019.01710.020.0...40.8142.094.472.1232.018.07.833.01.7416.5
12Lorenzo Montipòit ITAGKHellas Verona26-342199619.019.01710.031.0...43.5153.058.244.8261.010.03.846.02.4217.8
13Juan Mussoar ARGGKAtalanta28-267199413.013.01087.014.0...33.086.065.149.4147.08.05.410.00.8314.6
14Guillermo Ochoamx MEXGKSalernitana37-19919855.05.0450.014.0...43.352.078.854.778.02.02.64.00.8016.5
15André Onanacm CMRGKInter26-301199611.011.0990.012.0...31.079.035.437.9150.06.04.03.00.2713.0
16Rui Patríciopt PORGKRoma34-347198819.019.01710.016.0...31.4139.030.232.8221.06.02.713.00.6813.8
17Gianluca Pegoloit ITAGKSassuolo41-30919812.02.0180.03.0...29.716.031.328.328.02.07.10.00.009.0
18Mattia Perinit ITAGKJuventus30-07919927.06.0588.04.0...30.341.039.035.399.02.02.09.01.3817.8
19Ivan Provedelit ITAGKLazio28-317199419.018.01703.015.0...32.5115.034.834.8256.07.02.737.01.9618.1
20Ionuț Raduro ROUGKCremonese25-24519979.09.0810.019.0...37.367.050.746.3107.06.05.69.01.0014.5
21Luigi Sepeit ITAGKSalernitana31-265199115.015.01350.024.0...36.1134.046.340.6199.015.07.511.00.7314.2
22Marco Silvestriit ITAGKUdinese31-332199119.019.01710.021.0...33.5153.039.936.8253.04.01.69.00.4713.5
23Łukasz Skorupskipl POLGKBologna31-268199120.020.01800.030.0...32.1141.037.633.9280.018.06.417.00.8514.2
24Marco Sportielloit ITAGKAtalanta30-26319927.06.0623.09.0...28.561.068.948.986.07.08.114.02.0219.9
25Wojciech Szczęsnypl POLGKJuventus32-285199013.013.01122.011.0...36.161.041.039.2155.04.02.67.00.5614.2
26Ciprian Tătărușanuro ROUGKMilan36-353198612.012.01080.016.0...32.751.035.334.9125.08.06.410.00.8315.1
27Pietro Terraccianoit ITAGKFiorentina32-326199016.016.01440.023.0...33.3101.043.639.7149.07.04.730.01.8818.7
28Guglielmo Vicarioit ITAGKEmpoli26-113199619.019.01710.022.0...33.9103.045.641.8399.025.06.38.00.4210.5
29Jeroen Zoetnl NEDGKSpezia32-02219913.02.0154.01.0...41.78.087.556.624.01.04.23.01.7415.7
30Petar Zovkoba BIHGKSpezia20-30920021.00.074.02.0...35.113.076.951.124.01.04.22.02.4717.0
\n", "

31 rows × 47 columns

\n", "
" ], "text/plain": [ " player nationality position team age \\\n", "0 Emil Audero it ITA GK Sampdoria 26-010 \n", "1 Marco Carnesecchi it ITA GK Cremonese 22-211 \n", "2 Andrea Consigli it ITA GK Sassuolo 36-001 \n", "3 Michele Di Gregorio it ITA GK Monza 25-185 \n", "4 Bartłomiej Drągowski pl POL GK Spezia 25-162 \n", "5 Wladimiro Falcone it ITA GK Lecce 27-291 \n", "6 Pierluigi Gollini it ITA GK Fiorentina 27-316 \n", "7 Samir Handanović si SVN GK Inter 38-198 \n", "8 Mike Maignan fr FRA GK Milan 27-209 \n", "9 Luís Maximiano pt POR GK Lazio 24-023 \n", "10 Alex Meret it ITA GK Napoli 25-312 \n", "11 Vanja Milinković-Savić rs SRB GK Torino 25-342 \n", "12 Lorenzo Montipò it ITA GK Hellas Verona 26-342 \n", "13 Juan Musso ar ARG GK Atalanta 28-267 \n", "14 Guillermo Ochoa mx MEX GK Salernitana 37-199 \n", "15 André Onana cm CMR GK Inter 26-301 \n", "16 Rui Patrício pt POR GK Roma 34-347 \n", "17 Gianluca Pegolo it ITA GK Sassuolo 41-309 \n", "18 Mattia Perin it ITA GK Juventus 30-079 \n", "19 Ivan Provedel it ITA GK Lazio 28-317 \n", "20 Ionuț Radu ro ROU GK Cremonese 25-245 \n", "21 Luigi Sepe it ITA GK Salernitana 31-265 \n", "22 Marco Silvestri it ITA GK Udinese 31-332 \n", "23 Łukasz Skorupski pl POL GK Bologna 31-268 \n", "24 Marco Sportiello it ITA GK Atalanta 30-263 \n", "25 Wojciech Szczęsny pl POL GK Juventus 32-285 \n", "26 Ciprian Tătărușanu ro ROU GK Milan 36-353 \n", "27 Pietro Terracciano it ITA GK Fiorentina 32-326 \n", "28 Guglielmo Vicario it ITA GK Empoli 26-113 \n", "29 Jeroen Zoet nl NED GK Spezia 32-022 \n", "30 Petar Zovko ba BIH GK Spezia 20-309 \n", "\n", " birth_year gk_games gk_games_starts gk_minutes gk_goals_against ... \\\n", "0 1997 19.0 19.0 1710.0 32.0 ... \n", "1 2000 10.0 10.0 900.0 14.0 ... \n", "2 1987 17.0 17.0 1530.0 26.0 ... \n", "3 1997 19.0 19.0 1710.0 28.0 ... \n", "4 1997 18.0 18.0 1572.0 29.0 ... \n", "5 1995 20.0 20.0 1800.0 24.0 ... \n", "6 1995 3.0 3.0 270.0 2.0 ... \n", "7 1984 8.0 8.0 720.0 13.0 ... \n", "8 1995 7.0 7.0 630.0 8.0 ... \n", "9 1999 1.0 1.0 5.0 0.0 ... \n", "10 1997 19.0 19.0 1710.0 14.0 ... \n", "11 1997 19.0 19.0 1710.0 20.0 ... \n", "12 1996 19.0 19.0 1710.0 31.0 ... \n", "13 1994 13.0 13.0 1087.0 14.0 ... \n", "14 1985 5.0 5.0 450.0 14.0 ... \n", "15 1996 11.0 11.0 990.0 12.0 ... \n", "16 1988 19.0 19.0 1710.0 16.0 ... \n", "17 1981 2.0 2.0 180.0 3.0 ... \n", "18 1992 7.0 6.0 588.0 4.0 ... \n", "19 1994 19.0 18.0 1703.0 15.0 ... \n", "20 1997 9.0 9.0 810.0 19.0 ... \n", "21 1991 15.0 15.0 1350.0 24.0 ... \n", "22 1991 19.0 19.0 1710.0 21.0 ... \n", "23 1991 20.0 20.0 1800.0 30.0 ... \n", "24 1992 7.0 6.0 623.0 9.0 ... \n", "25 1990 13.0 13.0 1122.0 11.0 ... \n", "26 1986 12.0 12.0 1080.0 16.0 ... \n", "27 1990 16.0 16.0 1440.0 23.0 ... \n", "28 1996 19.0 19.0 1710.0 22.0 ... \n", "29 1991 3.0 2.0 154.0 1.0 ... \n", "30 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 38.8 142.0 57.7 \n", "1 40.0 66.0 59.1 \n", "2 34.4 157.0 31.8 \n", "3 33.0 115.0 31.3 \n", "4 34.4 106.0 63.2 \n", "5 40.9 156.0 75.0 \n", "6 32.4 11.0 63.6 \n", "7 26.1 45.0 4.4 \n", "8 33.5 18.0 38.9 \n", "9 0.0 0.0 0.0 \n", "10 26.6 114.0 20.2 \n", "11 40.8 142.0 94.4 \n", "12 43.5 153.0 58.2 \n", "13 33.0 86.0 65.1 \n", "14 43.3 52.0 78.8 \n", "15 31.0 79.0 35.4 \n", "16 31.4 139.0 30.2 \n", "17 29.7 16.0 31.3 \n", "18 30.3 41.0 39.0 \n", "19 32.5 115.0 34.8 \n", "20 37.3 67.0 50.7 \n", "21 36.1 134.0 46.3 \n", "22 33.5 153.0 39.9 \n", "23 32.1 141.0 37.6 \n", "24 28.5 61.0 68.9 \n", "25 36.1 61.0 41.0 \n", "26 32.7 51.0 35.3 \n", "27 33.3 101.0 43.6 \n", "28 33.9 103.0 45.6 \n", "29 41.7 8.0 87.5 \n", "30 35.1 13.0 76.9 \n", "\n", " gk_goal_kick_length_avg gk_crosses gk_crosses_stopped \\\n", "0 44.5 243.0 15.0 \n", "1 49.3 108.0 10.0 \n", "2 33.3 220.0 13.0 \n", "3 31.3 246.0 10.0 \n", "4 47.9 235.0 9.0 \n", "5 51.4 304.0 13.0 \n", "6 49.3 24.0 1.0 \n", "7 24.0 79.0 2.0 \n", "8 40.4 65.0 5.0 \n", "9 0.0 0.0 0.0 \n", "10 27.1 197.0 6.0 \n", "11 72.1 232.0 18.0 \n", "12 44.8 261.0 10.0 \n", "13 49.4 147.0 8.0 \n", "14 54.7 78.0 2.0 \n", "15 37.9 150.0 6.0 \n", "16 32.8 221.0 6.0 \n", "17 28.3 28.0 2.0 \n", "18 35.3 99.0 2.0 \n", "19 34.8 256.0 7.0 \n", "20 46.3 107.0 6.0 \n", "21 40.6 199.0 15.0 \n", "22 36.8 253.0 4.0 \n", "23 33.9 280.0 18.0 \n", "24 48.9 86.0 7.0 \n", "25 39.2 155.0 4.0 \n", "26 34.9 125.0 8.0 \n", "27 39.7 149.0 7.0 \n", "28 41.8 399.0 25.0 \n", "29 56.6 24.0 1.0 \n", "30 51.1 24.0 1.0 \n", "\n", " gk_crosses_stopped_pct gk_def_actions_outside_pen_area \\\n", "0 6.2 20.0 \n", "1 9.3 7.0 \n", "2 5.9 15.0 \n", "3 4.1 12.0 \n", "4 3.8 24.0 \n", "5 4.3 20.0 \n", "6 4.2 0.0 \n", "7 2.5 5.0 \n", "8 7.7 6.0 \n", "9 0.0 0.0 \n", "10 3.0 23.0 \n", "11 7.8 33.0 \n", "12 3.8 46.0 \n", "13 5.4 10.0 \n", "14 2.6 4.0 \n", "15 4.0 3.0 \n", "16 2.7 13.0 \n", "17 7.1 0.0 \n", "18 2.0 9.0 \n", "19 2.7 37.0 \n", "20 5.6 9.0 \n", "21 7.5 11.0 \n", "22 1.6 9.0 \n", "23 6.4 17.0 \n", "24 8.1 14.0 \n", "25 2.6 7.0 \n", "26 6.4 10.0 \n", "27 4.7 30.0 \n", "28 6.3 8.0 \n", "29 4.2 3.0 \n", "30 4.2 2.0 \n", "\n", " gk_def_actions_outside_pen_area_per90 gk_avg_distance_def_actions \n", "0 1.05 15.4 \n", "1 0.70 13.0 \n", "2 0.88 14.5 \n", "3 0.63 13.4 \n", "4 1.37 15.6 \n", "5 1.00 12.5 \n", "6 0.00 9.3 \n", "7 0.63 14.6 \n", "8 0.86 12.9 \n", "9 0.00 19.0 \n", "10 1.21 17.2 \n", "11 1.74 16.5 \n", "12 2.42 17.8 \n", "13 0.83 14.6 \n", "14 0.80 16.5 \n", "15 0.27 13.0 \n", "16 0.68 13.8 \n", "17 0.00 9.0 \n", "18 1.38 17.8 \n", "19 1.96 18.1 \n", "20 1.00 14.5 \n", "21 0.73 14.2 \n", "22 0.47 13.5 \n", "23 0.85 14.2 \n", "24 2.02 19.9 \n", "25 0.56 14.2 \n", "26 0.83 15.1 \n", "27 1.88 18.7 \n", "28 0.42 10.5 \n", "29 1.74 15.7 \n", "30 2.47 17.0 \n", "\n", "[31 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
0Atalanta24.048.419.0209.01710.036.025.06.08.0...231.0196.027.06.01.01.01117.0279.0239.053.9
1Bologna24.052.620.0220.01800.025.019.03.03.0...242.0238.041.03.05.02.01104.0180.0224.044.6
2Cremonese29.044.019.0209.01710.014.06.02.04.0...257.0194.044.03.04.01.01042.0267.0348.043.4
3Empoli26.046.319.0209.01710.017.09.00.00.0...222.0237.026.00.03.00.0907.0189.0217.046.6
4Fiorentina27.057.219.0209.01710.021.017.02.04.0...244.0249.025.02.02.01.01002.0289.0249.053.7
5Hellas Verona29.043.419.0209.01710.016.013.00.00.0...285.0185.043.00.01.01.01142.0388.0345.052.9
6Inter23.052.919.0209.01710.037.025.02.02.0...233.0229.032.01.02.02.0960.0232.0198.054.0
7Juventus26.049.519.0209.01710.030.023.02.03.0...227.0199.027.03.02.00.0965.0230.0230.050.0
8Lazio21.051.219.0209.01710.034.025.03.04.0...194.0252.026.02.01.00.0972.0181.0183.049.7
9Lecce26.042.520.0220.01800.018.012.01.02.0...283.0254.036.02.03.01.01097.0294.0373.044.1
10Milan27.054.519.0209.01710.033.028.02.02.0...236.0223.030.01.03.01.01015.0275.0224.055.1
11Monza29.055.119.0209.01710.022.013.03.03.0...248.0262.038.03.00.01.0906.0215.0197.052.2
12Napoli24.061.319.0209.01710.046.037.04.05.0...179.0240.033.04.02.00.01012.0231.0201.053.5
13Roma25.049.419.0209.01710.025.016.03.05.0...229.0250.032.04.00.00.01001.0225.0184.055.0
14Salernitana28.044.820.0220.01800.024.016.01.01.0...242.0207.042.00.07.00.01034.0240.0257.048.3
15Sampdoria29.049.419.0209.01710.08.07.00.00.0...278.0293.039.00.05.02.0968.0318.0300.051.5
16Sassuolo27.048.719.0209.01710.018.013.03.04.0...199.0236.016.03.04.00.0868.0173.0216.044.5
17Spezia30.046.720.0220.01800.015.010.02.02.0...281.0193.037.01.01.00.01136.0281.0322.046.6
18Torino23.052.819.0209.01710.019.014.01.01.0...277.0195.046.01.04.00.01002.0295.0323.047.7
19Udinese22.050.119.0209.01710.026.022.00.00.0...234.0238.033.00.02.00.0989.0237.0189.055.6
\n", "

20 rows × 157 columns

\n", "
" ], "text/plain": [ " team players_used possession games games_starts minutes \\\n", "0 Atalanta 24.0 48.4 19.0 209.0 1710.0 \n", "1 Bologna 24.0 52.6 20.0 220.0 1800.0 \n", "2 Cremonese 29.0 44.0 19.0 209.0 1710.0 \n", "3 Empoli 26.0 46.3 19.0 209.0 1710.0 \n", "4 Fiorentina 27.0 57.2 19.0 209.0 1710.0 \n", "5 Hellas Verona 29.0 43.4 19.0 209.0 1710.0 \n", "6 Inter 23.0 52.9 19.0 209.0 1710.0 \n", "7 Juventus 26.0 49.5 19.0 209.0 1710.0 \n", "8 Lazio 21.0 51.2 19.0 209.0 1710.0 \n", "9 Lecce 26.0 42.5 20.0 220.0 1800.0 \n", "10 Milan 27.0 54.5 19.0 209.0 1710.0 \n", "11 Monza 29.0 55.1 19.0 209.0 1710.0 \n", "12 Napoli 24.0 61.3 19.0 209.0 1710.0 \n", "13 Roma 25.0 49.4 19.0 209.0 1710.0 \n", "14 Salernitana 28.0 44.8 20.0 220.0 1800.0 \n", "15 Sampdoria 29.0 49.4 19.0 209.0 1710.0 \n", "16 Sassuolo 27.0 48.7 19.0 209.0 1710.0 \n", "17 Spezia 30.0 46.7 20.0 220.0 1800.0 \n", "18 Torino 23.0 52.8 19.0 209.0 1710.0 \n", "19 Udinese 22.0 50.1 19.0 209.0 1710.0 \n", "\n", " goals assists pens_made pens_att ... fouls fouled offsides \\\n", "0 36.0 25.0 6.0 8.0 ... 231.0 196.0 27.0 \n", "1 25.0 19.0 3.0 3.0 ... 242.0 238.0 41.0 \n", "2 14.0 6.0 2.0 4.0 ... 257.0 194.0 44.0 \n", "3 17.0 9.0 0.0 0.0 ... 222.0 237.0 26.0 \n", "4 21.0 17.0 2.0 4.0 ... 244.0 249.0 25.0 \n", "5 16.0 13.0 0.0 0.0 ... 285.0 185.0 43.0 \n", "6 37.0 25.0 2.0 2.0 ... 233.0 229.0 32.0 \n", "7 30.0 23.0 2.0 3.0 ... 227.0 199.0 27.0 \n", "8 34.0 25.0 3.0 4.0 ... 194.0 252.0 26.0 \n", "9 18.0 12.0 1.0 2.0 ... 283.0 254.0 36.0 \n", "10 33.0 28.0 2.0 2.0 ... 236.0 223.0 30.0 \n", "11 22.0 13.0 3.0 3.0 ... 248.0 262.0 38.0 \n", "12 46.0 37.0 4.0 5.0 ... 179.0 240.0 33.0 \n", "13 25.0 16.0 3.0 5.0 ... 229.0 250.0 32.0 \n", "14 24.0 16.0 1.0 1.0 ... 242.0 207.0 42.0 \n", "15 8.0 7.0 0.0 0.0 ... 278.0 293.0 39.0 \n", "16 18.0 13.0 3.0 4.0 ... 199.0 236.0 16.0 \n", "17 15.0 10.0 2.0 2.0 ... 281.0 193.0 37.0 \n", "18 19.0 14.0 1.0 1.0 ... 277.0 195.0 46.0 \n", "19 26.0 22.0 0.0 0.0 ... 234.0 238.0 33.0 \n", "\n", " pens_won pens_conceded own_goals ball_recoveries aerials_won \\\n", "0 6.0 1.0 1.0 1117.0 279.0 \n", "1 3.0 5.0 2.0 1104.0 180.0 \n", "2 3.0 4.0 1.0 1042.0 267.0 \n", "3 0.0 3.0 0.0 907.0 189.0 \n", "4 2.0 2.0 1.0 1002.0 289.0 \n", "5 0.0 1.0 1.0 1142.0 388.0 \n", "6 1.0 2.0 2.0 960.0 232.0 \n", "7 3.0 2.0 0.0 965.0 230.0 \n", "8 2.0 1.0 0.0 972.0 181.0 \n", "9 2.0 3.0 1.0 1097.0 294.0 \n", "10 1.0 3.0 1.0 1015.0 275.0 \n", "11 3.0 0.0 1.0 906.0 215.0 \n", "12 4.0 2.0 0.0 1012.0 231.0 \n", "13 4.0 0.0 0.0 1001.0 225.0 \n", "14 0.0 7.0 0.0 1034.0 240.0 \n", "15 0.0 5.0 2.0 968.0 318.0 \n", "16 3.0 4.0 0.0 868.0 173.0 \n", "17 1.0 1.0 0.0 1136.0 281.0 \n", "18 1.0 4.0 0.0 1002.0 295.0 \n", "19 0.0 2.0 0.0 989.0 237.0 \n", "\n", " aerials_lost aerials_won_pct \n", "0 239.0 53.9 \n", "1 224.0 44.6 \n", "2 348.0 43.4 \n", "3 217.0 46.6 \n", "4 249.0 53.7 \n", "5 345.0 52.9 \n", "6 198.0 54.0 \n", "7 230.0 50.0 \n", "8 183.0 49.7 \n", "9 373.0 44.1 \n", "10 224.0 55.1 \n", "11 197.0 52.2 \n", "12 201.0 53.5 \n", "13 184.0 55.0 \n", "14 257.0 48.3 \n", "15 300.0 51.5 \n", "16 216.0 44.5 \n", "17 322.0 46.6 \n", "18 323.0 47.7 \n", "19 189.0 55.6 \n", "\n", "[20 rows x 157 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 Atalanta24.051.619.0209.01710.022.016.01.01.0...209.0218.025.01.08.01.01165.0239.0279.046.1
1vs Bologna24.047.420.0220.01800.028.016.05.05.0...252.0229.033.03.03.01.01081.0224.0180.055.4
2vs Cremonese29.056.019.0209.01710.032.020.04.04.0...205.0247.029.03.04.00.01052.0348.0267.056.6
3vs Empoli26.053.719.0209.01710.022.016.01.03.0...251.0214.031.02.00.00.0999.0217.0189.053.4
4vs Fiorentina27.042.819.0209.01710.024.018.02.02.0...259.0229.052.01.04.00.0942.0249.0289.046.3
5vs Hellas Verona29.056.619.0209.01710.030.028.00.01.0...192.0276.022.01.00.01.01038.0345.0388.047.1
6vs Inter23.047.119.0209.01710.023.020.02.02.0...242.0214.018.02.02.01.0869.0198.0232.046.0
7vs Juventus26.050.519.0209.01710.015.012.01.02.0...210.0210.025.00.03.00.0947.0230.0230.050.0
8vs Lazio21.048.819.0209.01710.015.011.01.01.0...261.0185.042.01.04.01.01021.0183.0181.050.3
9vs Lecce26.057.620.0220.01800.023.016.03.03.0...263.0265.043.03.02.01.01072.0373.0294.055.9
10vs Milan27.045.519.0209.01710.023.017.02.03.0...234.0226.020.03.02.02.0964.0224.0275.044.9
11vs Monza29.044.919.0209.01710.027.021.00.00.0...279.0242.034.00.03.01.0958.0197.0215.047.8
12vs Napoli24.038.719.0209.01710.014.09.01.02.0...258.0167.027.01.04.00.0933.0201.0231.046.5
13vs Roma25.050.619.0209.01710.016.012.00.00.0...266.0214.010.00.05.00.0981.0184.0225.045.0
14vs Salernitana28.055.320.0220.01800.038.023.04.07.0...226.0233.049.07.01.01.01084.0257.0240.051.7
15vs Sampdoria29.050.619.0209.01710.030.021.04.06.0...299.0266.055.03.00.00.01017.0300.0318.048.5
16vs Sassuolo27.051.319.0209.01710.029.020.04.04.0...249.0182.062.02.04.00.0986.0216.0173.055.5
17vs Spezia30.053.420.0220.01800.032.027.00.01.0...207.0261.046.01.02.02.01182.0322.0281.053.4
18vs Torino23.047.219.0209.01710.020.012.03.04.0...209.0265.021.03.01.00.0998.0323.0295.052.3
19vs Udinese22.049.919.0209.01710.021.015.02.02.0...250.0227.029.02.00.01.0950.0189.0237.044.4
\n", "

20 rows × 157 columns

\n", "
" ], "text/plain": [ " team players_used possession games games_starts minutes \\\n", "0 vs Atalanta 24.0 51.6 19.0 209.0 1710.0 \n", "1 vs Bologna 24.0 47.4 20.0 220.0 1800.0 \n", "2 vs Cremonese 29.0 56.0 19.0 209.0 1710.0 \n", "3 vs Empoli 26.0 53.7 19.0 209.0 1710.0 \n", "4 vs Fiorentina 27.0 42.8 19.0 209.0 1710.0 \n", "5 vs Hellas Verona 29.0 56.6 19.0 209.0 1710.0 \n", "6 vs Inter 23.0 47.1 19.0 209.0 1710.0 \n", "7 vs Juventus 26.0 50.5 19.0 209.0 1710.0 \n", "8 vs Lazio 21.0 48.8 19.0 209.0 1710.0 \n", "9 vs Lecce 26.0 57.6 20.0 220.0 1800.0 \n", "10 vs Milan 27.0 45.5 19.0 209.0 1710.0 \n", "11 vs Monza 29.0 44.9 19.0 209.0 1710.0 \n", "12 vs Napoli 24.0 38.7 19.0 209.0 1710.0 \n", "13 vs Roma 25.0 50.6 19.0 209.0 1710.0 \n", "14 vs Salernitana 28.0 55.3 20.0 220.0 1800.0 \n", "15 vs Sampdoria 29.0 50.6 19.0 209.0 1710.0 \n", "16 vs Sassuolo 27.0 51.3 19.0 209.0 1710.0 \n", "17 vs Spezia 30.0 53.4 20.0 220.0 1800.0 \n", "18 vs Torino 23.0 47.2 19.0 209.0 1710.0 \n", "19 vs Udinese 22.0 49.9 19.0 209.0 1710.0 \n", "\n", " goals assists pens_made pens_att ... fouls fouled offsides \\\n", "0 22.0 16.0 1.0 1.0 ... 209.0 218.0 25.0 \n", "1 28.0 16.0 5.0 5.0 ... 252.0 229.0 33.0 \n", "2 32.0 20.0 4.0 4.0 ... 205.0 247.0 29.0 \n", "3 22.0 16.0 1.0 3.0 ... 251.0 214.0 31.0 \n", "4 24.0 18.0 2.0 2.0 ... 259.0 229.0 52.0 \n", "5 30.0 28.0 0.0 1.0 ... 192.0 276.0 22.0 \n", "6 23.0 20.0 2.0 2.0 ... 242.0 214.0 18.0 \n", "7 15.0 12.0 1.0 2.0 ... 210.0 210.0 25.0 \n", "8 15.0 11.0 1.0 1.0 ... 261.0 185.0 42.0 \n", "9 23.0 16.0 3.0 3.0 ... 263.0 265.0 43.0 \n", "10 23.0 17.0 2.0 3.0 ... 234.0 226.0 20.0 \n", "11 27.0 21.0 0.0 0.0 ... 279.0 242.0 34.0 \n", "12 14.0 9.0 1.0 2.0 ... 258.0 167.0 27.0 \n", "13 16.0 12.0 0.0 0.0 ... 266.0 214.0 10.0 \n", "14 38.0 23.0 4.0 7.0 ... 226.0 233.0 49.0 \n", "15 30.0 21.0 4.0 6.0 ... 299.0 266.0 55.0 \n", "16 29.0 20.0 4.0 4.0 ... 249.0 182.0 62.0 \n", "17 32.0 27.0 0.0 1.0 ... 207.0 261.0 46.0 \n", "18 20.0 12.0 3.0 4.0 ... 209.0 265.0 21.0 \n", "19 21.0 15.0 2.0 2.0 ... 250.0 227.0 29.0 \n", "\n", " pens_won pens_conceded own_goals ball_recoveries aerials_won \\\n", "0 1.0 8.0 1.0 1165.0 239.0 \n", "1 3.0 3.0 1.0 1081.0 224.0 \n", "2 3.0 4.0 0.0 1052.0 348.0 \n", "3 2.0 0.0 0.0 999.0 217.0 \n", "4 1.0 4.0 0.0 942.0 249.0 \n", "5 1.0 0.0 1.0 1038.0 345.0 \n", "6 2.0 2.0 1.0 869.0 198.0 \n", "7 0.0 3.0 0.0 947.0 230.0 \n", "8 1.0 4.0 1.0 1021.0 183.0 \n", "9 3.0 2.0 1.0 1072.0 373.0 \n", "10 3.0 2.0 2.0 964.0 224.0 \n", "11 0.0 3.0 1.0 958.0 197.0 \n", "12 1.0 4.0 0.0 933.0 201.0 \n", "13 0.0 5.0 0.0 981.0 184.0 \n", "14 7.0 1.0 1.0 1084.0 257.0 \n", "15 3.0 0.0 0.0 1017.0 300.0 \n", "16 2.0 4.0 0.0 986.0 216.0 \n", "17 1.0 2.0 2.0 1182.0 322.0 \n", "18 3.0 1.0 0.0 998.0 323.0 \n", "19 2.0 0.0 1.0 950.0 189.0 \n", "\n", " aerials_lost aerials_won_pct \n", "0 279.0 46.1 \n", "1 180.0 55.4 \n", "2 267.0 56.6 \n", "3 189.0 53.4 \n", "4 289.0 46.3 \n", "5 388.0 47.1 \n", "6 232.0 46.0 \n", "7 230.0 50.0 \n", "8 181.0 50.3 \n", "9 294.0 55.9 \n", "10 275.0 44.9 \n", "11 215.0 47.8 \n", "12 231.0 46.5 \n", "13 225.0 45.0 \n", "14 240.0 51.7 \n", "15 318.0 48.5 \n", "16 173.0 55.5 \n", "17 281.0 53.4 \n", "18 295.0 52.3 \n", "19 237.0 44.4 \n", "\n", "[20 rows x 157 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_dribbles'\n", " 'sca_shots' 'sca_fouled' 'gca' 'gca_per90' 'gca_passes_live'\n", " 'gca_passes_dead' 'gca_dribbles' 'gca_shots' 'gca_fouled' 'gca_defense'\n", " 'tackles' 'tackles_won' 'tackles_def_3rd' 'tackles_mid_3rd'\n", " 'tackles_att_3rd' 'dribble_tackles' 'dribbles_vs' 'dribble_tackles_pct'\n", " 'dribbled_past' 'blocks' 'blocked_shots' 'blocked_passes' 'interceptions'\n", " 'clearances' 'errors' 'touches' 'touches_def_pen_area' 'touches_def_3rd'\n", " 'touches_mid_3rd' 'touches_att_3rd' 'touches_att_pen_area'\n", " 'touches_live_ball' 'dribbles_completed' 'dribbles'\n", " 'dribbles_completed_pct' 'passes_received' 'miscontrols' 'dispossessed'\n", " 'cards_yellow_red' 'fouls' 'fouled' 'offsides' 'pens_won' 'pens_conceded'\n", " 'own_goals' 'ball_recoveries' 'aerials_won' 'aerials_lost'\n", " '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_dribbles' 'sca_shots' 'sca_fouled' 'gca'\n", " 'gca_per90' 'gca_passes_live' 'gca_passes_dead' 'gca_dribbles'\n", " 'gca_shots' 'gca_fouled' 'gca_defense' 'tackles' 'tackles_won'\n", " 'tackles_def_3rd' 'tackles_mid_3rd' 'tackles_att_3rd' 'dribble_tackles'\n", " 'dribbles_vs' 'dribble_tackles_pct' 'dribbled_past' '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'\n", " 'dribbles_completed' 'dribbles' 'dribbles_completed_pct'\n", " 'passes_received' 'miscontrols' 'dispossessed' 'cards_yellow_red' 'fouls'\n", " 'fouled' 'offsides' 'pens_won' 'pens_conceded' 'own_goals'\n", " 'ball_recoveries' 'aerials_won' '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_dribbles' 'sca_shots' 'sca_fouled' 'gca'\n", " 'gca_per90' 'gca_passes_live' 'gca_passes_dead' 'gca_dribbles'\n", " 'gca_shots' 'gca_fouled' 'gca_defense' 'tackles' 'tackles_won'\n", " 'tackles_def_3rd' 'tackles_mid_3rd' 'tackles_att_3rd' 'dribble_tackles'\n", " 'dribbles_vs' 'dribble_tackles_pct' 'dribbled_past' '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'\n", " 'dribbles_completed' 'dribbles' 'dribbles_completed_pct'\n", " 'passes_received' 'miscontrols' 'dispossessed' 'cards_yellow_red' 'fouls'\n", " 'fouled' 'offsides' 'pens_won' 'pens_conceded' 'own_goals'\n", " 'ball_recoveries' 'aerials_won' '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 × 120 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 120 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": 11, "id": "fa6258db", "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 Atalanta32.044.938.0418.03420.045.029.05.06.0...491.0488.069.04.06.03.02240.0518.0685.043.1
1vs Bologna36.049.338.0418.03420.053.032.08.09.0...527.0416.088.08.05.01.02032.0520.0492.051.4
2vs Cagliari33.055.638.0418.03420.067.041.07.010.0...526.0524.076.06.04.00.02112.0742.0696.051.6
3vs Empoli28.052.938.0418.03420.064.044.05.010.0...488.0482.066.07.07.03.02051.0549.0427.056.3
4vs Fiorentina28.041.838.0418.03420.049.033.03.05.0...585.0441.0119.04.012.00.01825.0456.0469.049.3
5vs Genoa40.056.138.0418.03420.058.035.04.05.0...523.0530.059.04.07.01.02257.0743.0635.053.9
6vs Hellas Verona31.049.438.0418.03420.057.038.03.04.0...463.0534.032.03.08.02.02206.0733.0689.051.5
7vs Inter27.043.438.0418.03420.031.019.04.04.0...440.0441.034.03.011.01.01767.0476.0549.046.4
8vs Juventus32.048.338.0418.03420.036.021.04.07.0...525.0471.035.05.06.01.01894.0440.0550.044.4
9vs Lazio27.044.438.0418.03420.057.040.05.06.0...474.0418.073.06.09.03.01956.0427.0411.051.0
10vs Milan28.045.838.0418.03420.029.019.04.05.0...533.0440.063.03.08.03.02106.0517.0521.049.8
11vs Napoli27.041.538.0418.03420.030.019.01.01.0...517.0415.060.00.014.00.01963.0403.0393.050.6
12vs Roma29.048.638.0418.03420.041.023.05.06.0...497.0477.081.05.09.01.01970.0441.0524.045.7
13vs Salernitana42.059.038.0418.03420.076.058.06.08.0...546.0463.063.06.05.01.02043.0506.0657.043.5
14vs Sampdoria34.054.138.0418.03420.061.041.03.04.0...538.0471.064.01.04.04.02174.0506.0609.045.4
15vs Sassuolo29.044.838.0418.03420.065.048.08.09.0...519.0434.0142.06.07.04.02041.0404.0343.054.1
16vs Spezia30.057.338.0418.03420.068.044.010.013.0...474.0477.062.08.05.03.02064.0589.0530.052.6
17vs Torino31.046.438.0418.03420.041.025.09.011.0...485.0611.060.010.06.03.01989.0891.0781.053.3
18vs Udinese29.057.738.0418.03420.057.039.05.07.0...494.0537.057.06.04.03.02010.0534.0453.054.1
19vs Venezia39.057.938.0418.03420.067.039.011.012.0...476.0492.048.05.05.00.02059.0583.0564.050.8
\n", "

20 rows × 157 columns

\n", "
" ], "text/plain": [ " team players_used possession games games_starts minutes \\\n", "0 vs Atalanta 32.0 44.9 38.0 418.0 3420.0 \n", "1 vs Bologna 36.0 49.3 38.0 418.0 3420.0 \n", "2 vs Cagliari 33.0 55.6 38.0 418.0 3420.0 \n", "3 vs Empoli 28.0 52.9 38.0 418.0 3420.0 \n", "4 vs Fiorentina 28.0 41.8 38.0 418.0 3420.0 \n", "5 vs Genoa 40.0 56.1 38.0 418.0 3420.0 \n", "6 vs Hellas Verona 31.0 49.4 38.0 418.0 3420.0 \n", "7 vs Inter 27.0 43.4 38.0 418.0 3420.0 \n", "8 vs Juventus 32.0 48.3 38.0 418.0 3420.0 \n", "9 vs Lazio 27.0 44.4 38.0 418.0 3420.0 \n", "10 vs Milan 28.0 45.8 38.0 418.0 3420.0 \n", "11 vs Napoli 27.0 41.5 38.0 418.0 3420.0 \n", "12 vs Roma 29.0 48.6 38.0 418.0 3420.0 \n", "13 vs Salernitana 42.0 59.0 38.0 418.0 3420.0 \n", "14 vs Sampdoria 34.0 54.1 38.0 418.0 3420.0 \n", "15 vs Sassuolo 29.0 44.8 38.0 418.0 3420.0 \n", "16 vs Spezia 30.0 57.3 38.0 418.0 3420.0 \n", "17 vs Torino 31.0 46.4 38.0 418.0 3420.0 \n", "18 vs Udinese 29.0 57.7 38.0 418.0 3420.0 \n", "19 vs Venezia 39.0 57.9 38.0 418.0 3420.0 \n", "\n", " goals assists pens_made pens_att ... fouls fouled offsides \\\n", "0 45.0 29.0 5.0 6.0 ... 491.0 488.0 69.0 \n", "1 53.0 32.0 8.0 9.0 ... 527.0 416.0 88.0 \n", "2 67.0 41.0 7.0 10.0 ... 526.0 524.0 76.0 \n", "3 64.0 44.0 5.0 10.0 ... 488.0 482.0 66.0 \n", "4 49.0 33.0 3.0 5.0 ... 585.0 441.0 119.0 \n", "5 58.0 35.0 4.0 5.0 ... 523.0 530.0 59.0 \n", "6 57.0 38.0 3.0 4.0 ... 463.0 534.0 32.0 \n", "7 31.0 19.0 4.0 4.0 ... 440.0 441.0 34.0 \n", "8 36.0 21.0 4.0 7.0 ... 525.0 471.0 35.0 \n", "9 57.0 40.0 5.0 6.0 ... 474.0 418.0 73.0 \n", "10 29.0 19.0 4.0 5.0 ... 533.0 440.0 63.0 \n", "11 30.0 19.0 1.0 1.0 ... 517.0 415.0 60.0 \n", "12 41.0 23.0 5.0 6.0 ... 497.0 477.0 81.0 \n", "13 76.0 58.0 6.0 8.0 ... 546.0 463.0 63.0 \n", "14 61.0 41.0 3.0 4.0 ... 538.0 471.0 64.0 \n", "15 65.0 48.0 8.0 9.0 ... 519.0 434.0 142.0 \n", "16 68.0 44.0 10.0 13.0 ... 474.0 477.0 62.0 \n", "17 41.0 25.0 9.0 11.0 ... 485.0 611.0 60.0 \n", "18 57.0 39.0 5.0 7.0 ... 494.0 537.0 57.0 \n", "19 67.0 39.0 11.0 12.0 ... 476.0 492.0 48.0 \n", "\n", " pens_won pens_conceded own_goals ball_recoveries aerials_won \\\n", "0 4.0 6.0 3.0 2240.0 518.0 \n", "1 8.0 5.0 1.0 2032.0 520.0 \n", "2 6.0 4.0 0.0 2112.0 742.0 \n", "3 7.0 7.0 3.0 2051.0 549.0 \n", "4 4.0 12.0 0.0 1825.0 456.0 \n", "5 4.0 7.0 1.0 2257.0 743.0 \n", "6 3.0 8.0 2.0 2206.0 733.0 \n", "7 3.0 11.0 1.0 1767.0 476.0 \n", "8 5.0 6.0 1.0 1894.0 440.0 \n", "9 6.0 9.0 3.0 1956.0 427.0 \n", "10 3.0 8.0 3.0 2106.0 517.0 \n", "11 0.0 14.0 0.0 1963.0 403.0 \n", "12 5.0 9.0 1.0 1970.0 441.0 \n", "13 6.0 5.0 1.0 2043.0 506.0 \n", "14 1.0 4.0 4.0 2174.0 506.0 \n", "15 6.0 7.0 4.0 2041.0 404.0 \n", "16 8.0 5.0 3.0 2064.0 589.0 \n", "17 10.0 6.0 3.0 1989.0 891.0 \n", "18 6.0 4.0 3.0 2010.0 534.0 \n", "19 5.0 5.0 0.0 2059.0 583.0 \n", "\n", " aerials_lost aerials_won_pct \n", "0 685.0 43.1 \n", "1 492.0 51.4 \n", "2 696.0 51.6 \n", "3 427.0 56.3 \n", "4 469.0 49.3 \n", "5 635.0 53.9 \n", "6 689.0 51.5 \n", "7 549.0 46.4 \n", "8 550.0 44.4 \n", "9 411.0 51.0 \n", "10 521.0 49.8 \n", "11 393.0 50.6 \n", "12 524.0 45.7 \n", "13 657.0 43.5 \n", "14 609.0 45.4 \n", "15 343.0 54.1 \n", "16 530.0 52.6 \n", "17 781.0 53.3 \n", "18 453.0 54.1 \n", "19 564.0 50.8 \n", "\n", "[20 rows x 157 columns]" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "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": 5, "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 }