{ "cells": [ { "cell_type": "markdown", "id": "1ee69dc3-2f18-4110-a232-81d807884da9", "metadata": {}, "source": [ "# FBRef" ] }, { "cell_type": "code", "execution_count": 1, "id": "2077b457-872d-420d-8799-9457e1a8f50f", "metadata": { "tags": [] }, "outputs": [], "source": [ "import sys\n", "\n", "sys.path.append(\"../../\")\n", "\n", "import penaltyblog as pb" ] }, { "cell_type": "markdown", "id": "56a9acc8-bf3a-4b1d-becb-f9b1e9ca1a09", "metadata": {}, "source": [ "## List available competitions" ] }, { "cell_type": "code", "execution_count": 2, "id": "bea88bf4-476f-4445-9345-379795d85025", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/plain": [ "['BEL First Division A',\n", " 'BEL First Division B',\n", " 'DEU Bundesliga 1',\n", " 'DEU Bundesliga 2',\n", " 'ENG Premier League',\n", " 'ENG Championship',\n", " 'ENG League 1',\n", " 'ENG League 2',\n", " 'ENG Conference',\n", " 'ESP La Liga',\n", " 'ESP La Liga Segunda',\n", " 'FRA Ligue 1',\n", " 'FRA Ligue 2',\n", " 'GRC Super League',\n", " 'ITA Serie A',\n", " 'ITA Serie B',\n", " 'NLD Eredivisie',\n", " 'PRT Liga 1',\n", " 'RUS Premier League',\n", " 'SCO Premier League',\n", " 'SCO Division 1',\n", " 'TUR Super Lig']" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pb.scrapers.FBRef.list_competitions()" ] }, { "cell_type": "markdown", "id": "c22b88a5-d0bc-4553-a1b6-700c630a36a7", "metadata": {}, "source": [ "## Get fixtures" ] }, { "cell_type": "code", "execution_count": 3, "id": "88b75ca5-90dd-4a6e-a0b4-4b1a5a63fec2", "metadata": { "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/martin/repos/penaltyblog/examples/scrapers/../../penaltyblog/scrapers/fbref.py:160: FutureWarning: Passing literal html to 'read_html' is deprecated and will be removed in a future version. To read from a literal string, wrap it in a 'StringIO' object.\n", " pd.read_html(content)[0]\n" ] }, { "data": { "text/html": [ "
\n", " | competition | \n", "season | \n", "datetime | \n", "week | \n", "day | \n", "date | \n", "time | \n", "team_home | \n", "xg_home | \n", "xg_away | \n", "team_away | \n", "attendance | \n", "venue | \n", "referee | \n", "goals_home | \n", "goals_away | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
1659657600---crystal_palace---arsenal | \n", "ENG Premier League | \n", "2022-2023 | \n", "2022-08-05 20:00:00 | \n", "1.0 | \n", "Fri | \n", "2022-08-05 | \n", "20:00 | \n", "Crystal Palace | \n", "1.2 | \n", "1.0 | \n", "Arsenal | \n", "25286.0 | \n", "Selhurst Park | \n", "Anthony Taylor | \n", "0.0 | \n", "2.0 | \n", "
1659744000---bournemouth---aston_villa | \n", "ENG Premier League | \n", "2022-2023 | \n", "2022-08-06 15:00:00 | \n", "1.0 | \n", "Sat | \n", "2022-08-06 | \n", "15:00 | \n", "Bournemouth | \n", "0.6 | \n", "0.7 | \n", "Aston Villa | \n", "11013.0 | \n", "Vitality Stadium | \n", "Peter Bankes | \n", "2.0 | \n", "0.0 | \n", "
1659744000---everton---chelsea | \n", "ENG Premier League | \n", "2022-2023 | \n", "2022-08-06 17:30:00 | \n", "1.0 | \n", "Sat | \n", "2022-08-06 | \n", "17:30 | \n", "Everton | \n", "0.7 | \n", "1.5 | \n", "Chelsea | \n", "39254.0 | \n", "Goodison Park | \n", "Craig Pawson | \n", "0.0 | \n", "1.0 | \n", "
1659744000---fulham---liverpool | \n", "ENG Premier League | \n", "2022-2023 | \n", "2022-08-06 12:30:00 | \n", "1.0 | \n", "Sat | \n", "2022-08-06 | \n", "12:30 | \n", "Fulham | \n", "1.2 | \n", "1.2 | \n", "Liverpool | \n", "22207.0 | \n", "Craven Cottage | \n", "Andy Madley | \n", "2.0 | \n", "2.0 | \n", "
1659744000---leeds_united---wolves | \n", "ENG Premier League | \n", "2022-2023 | \n", "2022-08-06 15:00:00 | \n", "1.0 | \n", "Sat | \n", "2022-08-06 | \n", "15:00 | \n", "Leeds United | \n", "0.8 | \n", "1.3 | \n", "Wolves | \n", "36347.0 | \n", "Elland Road | \n", "Robert Jones | \n", "2.0 | \n", "1.0 | \n", "
\n", " | nation | \n", "pos | \n", "squad | \n", "born | \n", "playing_time_mp | \n", "playing_time_starts | \n", "playing_time_min | \n", "playing_time_90s | \n", "performance_gls | \n", "performance_ast | \n", "... | \n", "per_90_minutes_g-pk | \n", "per_90_minutes_g+a-pk | \n", "per_90_minutes_xg | \n", "per_90_minutes_xag | \n", "per_90_minutes_xg+xag | \n", "per_90_minutes_npxg | \n", "per_90_minutes_npxg+xag | \n", "season | \n", "competition | \n", "age_years | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
player | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
Aaron Cresswell | \n", "eng ENG | \n", "DF | \n", "West Ham | \n", "1989 | \n", "28.0 | \n", "24.0 | \n", "2235.0 | \n", "24.8 | \n", "0 | \n", "1 | \n", "... | \n", "0.00 | \n", "0.04 | \n", "0.01 | \n", "0.15 | \n", "0.16 | \n", "0.01 | \n", "0.16 | \n", "2022-2023 | \n", "ENG Premier League | \n", "32.0 | \n", "
Aaron Hickey | \n", "sct SCO | \n", "DF | \n", "Brentford | \n", "2002 | \n", "26.0 | \n", "23.0 | \n", "1916.0 | \n", "21.3 | \n", "0 | \n", "1 | \n", "... | \n", "0.00 | \n", "0.05 | \n", "0.02 | \n", "0.02 | \n", "0.04 | \n", "0.02 | \n", "0.04 | \n", "2022-2023 | \n", "ENG Premier League | \n", "20.0 | \n", "
Aaron Ramsdale | \n", "eng ENG | \n", "GK | \n", "Arsenal | \n", "1998 | \n", "38.0 | \n", "38.0 | \n", "3420.0 | \n", "38.0 | \n", "0 | \n", "0 | \n", "... | \n", "0.00 | \n", "0.00 | \n", "0.00 | \n", "0.00 | \n", "0.00 | \n", "0.00 | \n", "0.00 | \n", "2022-2023 | \n", "ENG Premier League | \n", "24.0 | \n", "
Aaron Wan-Bissaka | \n", "eng ENG | \n", "DF | \n", "Manchester Utd | \n", "1997 | \n", "19.0 | \n", "16.0 | \n", "1435.0 | \n", "15.9 | \n", "0 | \n", "0 | \n", "... | \n", "0.00 | \n", "0.00 | \n", "0.07 | \n", "0.06 | \n", "0.14 | \n", "0.07 | \n", "0.14 | \n", "2022-2023 | \n", "ENG Premier League | \n", "24.0 | \n", "
Abdoulaye Doucouré | \n", "ml MLI | \n", "MF | \n", "Everton | \n", "1993 | \n", "25.0 | \n", "17.0 | \n", "1533.0 | \n", "17.0 | \n", "5 | \n", "2 | \n", "... | \n", "0.29 | \n", "0.41 | \n", "0.14 | \n", "0.13 | \n", "0.27 | \n", "0.14 | \n", "0.27 | \n", "2022-2023 | \n", "ENG Premier League | \n", "29.0 | \n", "
5 rows × 36 columns
\n", "\n", " | #_pl | \n", "age | \n", "poss | \n", "playing_time_mp | \n", "playing_time_starts | \n", "playing_time_min | \n", "playing_time_90s | \n", "performance_gls | \n", "performance_ast | \n", "performance_g+a | \n", "... | \n", "per_90_minutes_g+a | \n", "per_90_minutes_g-pk | \n", "per_90_minutes_g+a-pk | \n", "per_90_minutes_xg | \n", "per_90_minutes_xag | \n", "per_90_minutes_xg+xag | \n", "per_90_minutes_npxg | \n", "per_90_minutes_npxg+xag | \n", "season | \n", "competition | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
squad | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
Arsenal | \n", "26 | \n", "24.7 | \n", "59.3 | \n", "38.0 | \n", "418.0 | \n", "3420.0 | \n", "38.0 | \n", "84 | \n", "64 | \n", "148 | \n", "... | \n", "3.89 | \n", "2.13 | \n", "3.82 | \n", "1.88 | \n", "1.41 | \n", "3.29 | \n", "1.81 | \n", "3.22 | \n", "2022-2023 | \n", "ENG Premier League | \n", "
Aston Villa | \n", "26 | \n", "27.0 | \n", "49.3 | \n", "38.0 | \n", "418.0 | \n", "3420.0 | \n", "38.0 | \n", "49 | \n", "35 | \n", "84 | \n", "... | \n", "2.21 | \n", "1.21 | \n", "2.13 | \n", "1.32 | \n", "1.02 | \n", "2.34 | \n", "1.24 | \n", "2.26 | \n", "2022-2023 | \n", "ENG Premier League | \n", "
Bournemouth | \n", "31 | \n", "26.3 | \n", "40.4 | \n", "38.0 | \n", "418.0 | \n", "3420.0 | \n", "38.0 | \n", "37 | \n", "24 | \n", "61 | \n", "... | \n", "1.61 | \n", "0.97 | \n", "1.61 | \n", "1.01 | \n", "0.75 | \n", "1.76 | \n", "1.01 | \n", "1.76 | \n", "2022-2023 | \n", "ENG Premier League | \n", "
Brentford | \n", "25 | \n", "26.2 | \n", "43.8 | \n", "38.0 | \n", "418.0 | \n", "3420.0 | \n", "38.0 | \n", "56 | \n", "36 | \n", "92 | \n", "... | \n", "2.42 | \n", "1.29 | \n", "2.24 | \n", "1.48 | \n", "1.01 | \n", "2.49 | \n", "1.32 | \n", "2.33 | \n", "2022-2023 | \n", "ENG Premier League | \n", "
Brighton | \n", "29 | \n", "26.3 | \n", "60.2 | \n", "38.0 | \n", "418.0 | \n", "3420.0 | \n", "38.0 | \n", "68 | \n", "46 | \n", "114 | \n", "... | \n", "3.00 | \n", "1.63 | \n", "2.84 | \n", "1.93 | \n", "1.37 | \n", "3.30 | \n", "1.81 | \n", "3.19 | \n", "2022-2023 | \n", "ENG Premier League | \n", "
5 rows × 33 columns
\n", "\n", " | #_pl | \n", "age | \n", "poss | \n", "playing_time_mp | \n", "playing_time_starts | \n", "playing_time_min | \n", "playing_time_90s | \n", "performance_gls | \n", "performance_ast | \n", "performance_g+a | \n", "... | \n", "per_90_minutes_g+a | \n", "per_90_minutes_g-pk | \n", "per_90_minutes_g+a-pk | \n", "per_90_minutes_xg | \n", "per_90_minutes_xag | \n", "per_90_minutes_xg+xag | \n", "per_90_minutes_npxg | \n", "per_90_minutes_npxg+xag | \n", "season | \n", "competition | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
squad | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
vs Arsenal | \n", "26 | \n", "26.7 | \n", "40.1 | \n", "38.0 | \n", "418.0 | \n", "3420.0 | \n", "38.0 | \n", "42 | \n", "27 | \n", "69 | \n", "... | \n", "1.82 | \n", "1.03 | \n", "1.74 | \n", "1.10 | \n", "0.83 | \n", "1.93 | \n", "1.00 | \n", "1.83 | \n", "2022-2023 | \n", "ENG Premier League | \n", "
vs Aston Villa | \n", "26 | \n", "26.5 | \n", "50.6 | \n", "38.0 | \n", "418.0 | \n", "3420.0 | \n", "38.0 | \n", "42 | \n", "25 | \n", "67 | \n", "... | \n", "1.76 | \n", "0.97 | \n", "1.63 | \n", "1.38 | \n", "0.95 | \n", "2.33 | \n", "1.26 | \n", "2.21 | \n", "2022-2023 | \n", "ENG Premier League | \n", "
vs Bournemouth | \n", "31 | \n", "26.6 | \n", "59.9 | \n", "38.0 | \n", "418.0 | \n", "3420.0 | \n", "38.0 | \n", "68 | \n", "49 | \n", "117 | \n", "... | \n", "3.08 | \n", "1.63 | \n", "2.92 | \n", "1.68 | \n", "1.19 | \n", "2.87 | \n", "1.54 | \n", "2.73 | \n", "2022-2023 | \n", "ENG Premier League | \n", "
vs Brentford | \n", "25 | \n", "26.6 | \n", "56.6 | \n", "38.0 | \n", "418.0 | \n", "3420.0 | \n", "38.0 | \n", "43 | \n", "30 | \n", "73 | \n", "... | \n", "1.92 | \n", "1.08 | \n", "1.87 | \n", "1.28 | \n", "0.94 | \n", "2.22 | \n", "1.25 | \n", "2.19 | \n", "2022-2023 | \n", "ENG Premier League | \n", "
vs Brighton | \n", "29 | \n", "26.5 | \n", "39.5 | \n", "38.0 | \n", "418.0 | \n", "3420.0 | \n", "38.0 | \n", "47 | \n", "34 | \n", "81 | \n", "... | \n", "2.13 | \n", "1.08 | \n", "1.97 | \n", "1.32 | \n", "0.89 | \n", "2.21 | \n", "1.15 | \n", "2.04 | \n", "2022-2023 | \n", "ENG Premier League | \n", "
5 rows × 33 columns
\n", "