football-data.co.uk
[1]:
import sys
sys.path.append("../")
import penaltyblog as pb
[2]:
pb.__version__
[2]:
'0.4.0'
List the available countries to download data for
[3]:
pb.scrapers.FootballData.list_competitions()
[3]:
['DEU Bundesliga 1',
'DEU Bundesliga 2',
'ENG Premier League',
'ENG Championship',
'ENG League 1',
'ENG League 2',
'ENG Conference',
'FRA Ligue 1',
'FRA Ligue 2',
'GRC Super League',
'ITA Serie A',
'ITA Serie B',
'NLD Eredivisie',
'PRT Liga 1',
'SCO Premier League',
'SCO Division 1',
'SCO Division 2',
'SCO Division 3',
'TUR Super Lig']
Download the data for the English Premier League
[4]:
fb = pb.scrapers.FootballData("ENG Premier League", "2021-2022")
df = fb.get_fixtures()
df.head()
[4]:
competition | season | datetime | div | date | time | team_home | team_away | fthg | ftag | ... | avg_c<2.5 | ah_ch | b365_cahh | b365_caha | pcahh | pcaha | max_cahh | max_caha | avg_cahh | avg_caha | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | |||||||||||||||||||||
1628812800---brentford---arsenal | ENG Premier League | 2021-2022 | 2021-08-13 20:00:00 | E0 | 2021-08-13 | 20:00 | Brentford | Arsenal | 2 | 0 | ... | 1.62 | 0.50 | 1.75 | 2.05 | 1.81 | 2.13 | 2.05 | 2.17 | 1.80 | 2.09 |
1628899200---burnley---brighton | ENG Premier League | 2021-2022 | 2021-08-14 15:00:00 | E0 | 2021-08-14 | 15:00 | Burnley | Brighton | 1 | 2 | ... | 1.62 | 0.25 | 1.79 | 2.15 | 1.81 | 2.14 | 1.82 | 2.19 | 1.79 | 2.12 |
1628899200---chelsea---crystal_palace | ENG Premier League | 2021-2022 | 2021-08-14 15:00:00 | E0 | 2021-08-14 | 15:00 | Chelsea | Crystal Palace | 3 | 0 | ... | 1.94 | -1.50 | 2.05 | 1.75 | 2.12 | 1.81 | 2.16 | 1.93 | 2.06 | 1.82 |
1628899200---everton---southampton | ENG Premier League | 2021-2022 | 2021-08-14 15:00:00 | E0 | 2021-08-14 | 15:00 | Everton | Southampton | 3 | 1 | ... | 1.67 | -0.50 | 2.05 | 1.88 | 2.05 | 1.88 | 2.08 | 1.90 | 2.03 | 1.86 |
1628899200---leicester---wolves | ENG Premier League | 2021-2022 | 2021-08-14 15:00:00 | E0 | 2021-08-14 | 15:00 | Leicester | Wolves | 1 | 0 | ... | 1.79 | -0.75 | 2.02 | 1.91 | 2.01 | 1.92 | 2.05 | 1.95 | 1.99 | 1.89 |
5 rows × 109 columns
Download the data for the English Premier League and map team names
[8]:
team_mappings = pb.scrapers.get_example_team_name_mappings()
fb = pb.scrapers.FootballData("ENG Premier League", "2021-2022", team_mappings)
df = fb.get_fixtures()
df.head()
[8]:
competition | season | datetime | div | date | time | team_home | team_away | fthg | ftag | ... | avg_c<2.5 | ah_ch | b365_cahh | b365_caha | pcahh | pcaha | max_cahh | max_caha | avg_cahh | avg_caha | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | |||||||||||||||||||||
1628812800---brentford---arsenal | ENG Premier League | 2021-2022 | 2021-08-13 20:00:00 | E0 | 2021-08-13 | 20:00 | Brentford | Arsenal | 2 | 0 | ... | 1.62 | 0.50 | 1.75 | 2.05 | 1.81 | 2.13 | 2.05 | 2.17 | 1.80 | 2.09 |
1628899200---burnley---brighton | ENG Premier League | 2021-2022 | 2021-08-14 15:00:00 | E0 | 2021-08-14 | 15:00 | Burnley | Brighton | 1 | 2 | ... | 1.62 | 0.25 | 1.79 | 2.15 | 1.81 | 2.14 | 1.82 | 2.19 | 1.79 | 2.12 |
1628899200---chelsea---crystal_palace | ENG Premier League | 2021-2022 | 2021-08-14 15:00:00 | E0 | 2021-08-14 | 15:00 | Chelsea | Crystal Palace | 3 | 0 | ... | 1.94 | -1.50 | 2.05 | 1.75 | 2.12 | 1.81 | 2.16 | 1.93 | 2.06 | 1.82 |
1628899200---everton---southampton | ENG Premier League | 2021-2022 | 2021-08-14 15:00:00 | E0 | 2021-08-14 | 15:00 | Everton | Southampton | 3 | 1 | ... | 1.67 | -0.50 | 2.05 | 1.88 | 2.05 | 1.88 | 2.08 | 1.90 | 2.03 | 1.86 |
1628899200---leicester_city---wolverhampton_wanderers | ENG Premier League | 2021-2022 | 2021-08-14 15:00:00 | E0 | 2021-08-14 | 15:00 | Leicester City | Wolverhampton Wanderers | 1 | 0 | ... | 1.79 | -0.75 | 2.02 | 1.91 | 2.01 | 1.92 | 2.05 | 1.95 | 1.99 | 1.89 |
5 rows × 109 columns
[10]:
"Wolverhampton Wanderers" in df["team_home"].unique()
[10]:
True
[9]:
df["team_home"].unique()
[9]:
array(['Brentford', 'Burnley', 'Chelsea', 'Everton', 'Leicester City',
'Manchester United', 'Norwich City', 'Watford', 'Newcastle United',
'Tottenham Hotspur', 'Aston Villa', 'Brighton', 'Crystal Palace',
'Leeds United', 'Liverpool', 'Manchester City', 'Arsenal',
'Southampton', 'Wolverhampton Wanderers', 'West Ham'], dtype=object)
[ ]: