This page was generated from doc/datasources/FBref.ipynb.
You can download the notebook,
[3]:
import soccerdata as sd
No entry for terminal type "xterm-color";
using dumb terminal settings.

FBref

[4]:
fbref = sd.FBref(leagues="ENG-Premier League", seasons=2021)
print(fbref.__doc__)
Provides pd.DataFrames from data at http://fbref.com.

    Data will be downloaded as necessary and cached locally in
    ``~/soccerdata/data/FBref``.

    Parameters
    ----------
    leagues : string or iterable, optional
        IDs of leagues to include. For efficiently reading data from the Top-5
        European leagues, use "Big 5 European Leagues Combined".
    seasons : string, int or list, optional
        Seasons to include. Supports multiple formats.
        Examples: '16-17'; 2016; '2016-17'; [14, 15, 16]
    proxy : 'tor' or or dict or list(dict) or callable, optional
        Use a proxy to hide your IP address. Valid options are:
            - "tor": Uses the Tor network. Tor should be running in
              the background on port 9050.
            - str: The address of the proxy server to use.
            - list(str): A list of proxies to choose from. A different proxy will
              be selected from this list after failed requests, allowing rotating
              proxies.
            - callable: A function that returns a valid proxy. This function will
              be called after failed requests, allowing rotating proxies.
    no_cache : bool
        If True, will not use cached data.
    no_store : bool
        If True, will not store downloaded data.
    data_dir : Path
        Path to directory where data will be cached.
    path_to_browser : Path, optional
        Path to the Chrome executable.
    headless : bool, default: True
        If True, will run Chrome in headless mode. Setting this to False might
        help to avoid getting blocked. Only supported for Selenium <4.13.

Team season stats

[5]:
team_season_stats = fbref.read_team_season_stats(stat_type="shooting")
team_season_stats.head()
[5]:
players_used 90s Standard url
Gls Sh SoT SoT% Sh/90 SoT/90 G/Sh G/SoT PK PKatt
league season team
ENG-Premier League 2021 Arsenal 29 38 53 453 140 30.9 11.92 3.68 0.1 0.34 6 6 /en/squads/18bb7c10/2020-2021/Arsenal-Stats
Aston Villa 24 38 52 514 178 34.6 13.53 4.68 0.09 0.26 5 6 /en/squads/8602292d/2020-2021/Aston-Villa-Stats
Brighton 27 38 39 478 134 28.0 12.58 3.53 0.07 0.25 6 9 /en/squads/d07537b9/2020-2021/Brighton-and-Hov...
Burnley 25 38 32 381 124 32.5 10.03 3.26 0.08 0.23 3 3 /en/squads/943e8050/2020-2021/Burnley-Stats
Chelsea 27 38 56 546 193 35.3 14.37 5.08 0.09 0.25 8 10 /en/squads/cff3d9bb/2020-2021/Chelsea-Stats

Team match stats

[6]:
team_match_stats = fbref.read_team_match_stats(stat_type="schedule", team="Manchester City")
team_match_stats.head()
[6]:
date time round day venue result GF GA opponent Poss Attendance Captain Formation Opp Formation Referee match_report Notes
league season team game
ENG-Premier League 2021 Manchester City 2020-09-21 Wolves-Manchester City 2020-09-21 20:15:00 Matchweek 2 Mon Away W 3 1 Wolves 65 <NA> Fernandinho 4-2-3-1 5-3-2 Andre Marriner /en/matches/1c17eca3/Wolverhampton-Wanderers-M... <NA>
2020-09-27 Manchester City-Leicester City 2020-09-27 16:30:00 Matchweek 3 Sun Home L 2 5 Leicester City 72 <NA> Fernandinho 4-2-3-1 5-4-1 Michael Oliver /en/matches/31c2a061/Manchester-City-Leicester... <NA>
2020-10-03 Leeds United-Manchester City 2020-10-03 17:30:00 Matchweek 4 Sat Away D 1 1 Leeds United 48 <NA> Kevin De Bruyne 4-3-3 4-1-4-1 Mike Dean /en/matches/5ce15b58/Leeds-United-Manchester-C... <NA>
2020-10-17 Manchester City-Arsenal 2020-10-17 17:30:00 Matchweek 5 Sat Home W 1 0 Arsenal 59 <NA> Raheem Sterling 3-1-4-2 4-3-3 Chris Kavanagh /en/matches/e95b8546/Manchester-City-Arsenal-O... <NA>
2020-10-24 West Ham United-Manchester City 2020-10-24 12:30:00 Matchweek 6 Sat Away D 1 1 West Ham United 70 <NA> Raheem Sterling 4-3-3 5-4-1 Anthony Taylor /en/matches/2b0c0eca/West-Ham-United-Mancheste... <NA>

Player season stats

[7]:
player_season_stats = fbref.read_player_season_stats(stat_type="standard")
player_season_stats.head()
[7]:
nation pos age born Playing Time Performance Per 90 Minutes
MP Starts Min 90s Gls Ast G+A G-PK PK PKatt CrdY CrdR Gls Ast G+A G-PK G+A-PK
league season team player
ENG-Premier League 2021 Arsenal Ainsley Maitland-Niles ENG MF,DF 22 1997 11 5 490 5.4 0 0 0 0 0 0 0 0 0.0 0.0 0.0 0.0 0.0
Alexandre Lacazette FRA FW 29 1991 31 22 1923 21.4 13 2 15 10 3 3 3 0 0.61 0.09 0.7 0.47 0.56
Bernd Leno GER GK 28 1992 35 35 3131 34.8 0 0 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0
Bukayo Saka ENG MF 18 2001 32 30 2553 28.4 5 3 8 5 0 0 1 0 0.18 0.11 0.28 0.18 0.28
Calum Chambers ENG DF 25 1995 10 8 753 8.4 0 2 2 0 0 0 0 0 0.0 0.24 0.24 0.0 0.24

Player match stats

[9]:
player_match_stats = fbref.read_player_match_stats(stat_type="summary", match_id="db261cb0")
player_match_stats.head()
[9]:
jersey_number nation pos age min Performance game_id
Gls Ast PK PKatt Sh SoT CrdY CrdR Fls Fld Off Crs TklW Int OG PKwon PKcon
league season game team player
ENG-Premier League 2021 2020-09-12 Crystal Palace-Southampton Crystal Palace Andros Townsend 10 ENG RM 29-058 90 0 1 0 0 0 0 0 0 1 1 1 3 0 1 0 <NA> <NA> db261cb0
Cheikhou Kouyaté 8 SEN CB 30-266 90 0 0 0 0 1 1 0 0 2 1 0 0 0 0 0 <NA> <NA> db261cb0
Eberechi Eze 25 ENG FW,MF 22-075 10 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 <NA> <NA> db261cb0
James McArthur 18 SCO CM 32-341 90 0 0 0 0 1 0 0 0 1 2 0 0 1 3 0 <NA> <NA> db261cb0
James McCarthy 22 IRL CM 29-305 73 0 0 0 0 0 0 1 0 3 1 0 4 1 2 0 <NA> <NA> db261cb0

Game schedule

[10]:
epl_schedule = fbref.read_schedule()
epl_schedule.head()
[10]:
week day date time home_team score away_team attendance venue referee match_report notes game_id
league season game
ENG-Premier League 2021 2020-09-12 Crystal Palace-Southampton 1 Sat 2020-09-12 15:00 (16:00) Crystal Palace 1–0 Southampton <NA> Selhurst Park Jonathan Moss /en/matches/db261cb0/Crystal-Palace-Southampto... <NA> db261cb0
2020-09-12 Fulham-Arsenal 1 Sat 2020-09-12 12:30 (13:30) Fulham 0–3 Arsenal <NA> Craven Cottage Chris Kavanagh /en/matches/bf52349b/Fulham-Arsenal-September-... <NA> bf52349b
2020-09-12 Liverpool-Leeds United 1 Sat 2020-09-12 17:30 (18:30) Liverpool 4–3 Leeds United <NA> Anfield Michael Oliver /en/matches/21b58926/Liverpool-Leeds-United-Se... <NA> 21b58926
2020-09-12 West Ham United-Newcastle United 1 Sat 2020-09-12 20:00 (21:00) West Ham United 0–2 Newcastle United <NA> London Stadium Stuart Attwell /en/matches/78495ced/West-Ham-United-Newcastle... <NA> 78495ced
2020-09-13 Tottenham Hotspur-Everton 1 Sun 2020-09-13 16:30 (17:30) Tottenham Hotspur 0–1 Everton <NA> Tottenham Hotspur Stadium Martin Atkinson /en/matches/fc7f9aa1/Tottenham-Hotspur-Everton... <NA> fc7f9aa1

Line ups

[11]:
lineups = fbref.read_lineup(match_id="db261cb0")
lineups.head()
[11]:
jersey_number player team is_starter position minutes_played
league season game
ENG-Premier League 2021 2020-09-12 Crystal Palace-Southampton 31 Vicente Guaita Crystal Palace True GK 90
2020-09-12 Crystal Palace-Southampton 2 Joel Ward Crystal Palace True RB 90
2020-09-12 Crystal Palace-Southampton 6 Scott Dann Crystal Palace True CB 90
2020-09-12 Crystal Palace-Southampton 8 Cheikhou Kouyaté Crystal Palace True CB 90
2020-09-12 Crystal Palace-Southampton 9 Jordan Ayew Crystal Palace True FW 90

Events

[12]:
events = fbref.read_events(match_id="db261cb0")
events.head()
[12]:
team minute score player1 player2 event_type
league season game
ENG-Premier League 2021 2020-09-12 Crystal Palace-Southampton Crystal Palace 13’ 1:0 Wilfried Zaha Andros Townsend goal
2020-09-12 Crystal Palace-Southampton Crystal Palace 41’ 1:0 Jeffrey Schlupp None yellow_card
2020-09-12 Crystal Palace-Southampton Southampton 46’ 1:0 Jannik Vestergaard Jan Bednarek substitute_in
2020-09-12 Crystal Palace-Southampton Southampton 51’ 1:0 Kyle Walker-Peters None yellow_card
2020-09-12 Crystal Palace-Southampton Crystal Palace 58’ 1:0 James McCarthy None yellow_card