[3]:
import soccerdata as sd
FiveThirtyEight¶
[4]:
five38 = sd.FiveThirtyEight(leagues="ENG-Premier League", seasons=2021)
print(five38.__doc__)
/cw/dtaijupiter/NoCsBack/dtai/pieterr/Projects/soccerdata/soccerdata/_common.py:466: UserWarning: Season id "2021" is ambiguous: interpreting as "20-21"
warnings.warn(msg)
Provides pd.DataFrames from fivethirtyeight's "Club Soccer Predictions" project.
Data will be downloaded as necessary and cached locally in
``~/soccerdata/data/FiveThirtyEight``.
Original project and background info:
https://projects.fivethirtyeight.com/soccer-predictions/ and
https://fivethirtyeight.com/features/how-our-club-soccer-projections-work/
Parameters
----------
leagues : string or iterable, optional
IDs of Leagues to include.
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.
- dict: A dictionary with the proxy to use. The dict should be
a mapping of supported protocols to proxy addresses. For example::
{
'http': 'http://10.10.1.10:3128',
'https': 'http://10.10.1.10:1080',
}
- list(dict): 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.
Game schedule and predicted results¶
[5]:
epl_schedule = five38.read_games()
epl_schedule.head()
[5]:
date | status | leg | home_team | away_team | home_id | away_id | home_code | away_code | prob_home | prob_away | prob_tie | round | matchday | score_home | score_away | adj_score_home | adj_score_away | chances_home | chances_away | moves_home | moves_away | aggregate_winner | shootout_winner | |||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
league | season | game | ||||||||||||||||||||||||
ENG-Premier League | 2021 | 2020-09-12 Crystal Palace-Southampton | 2020-09-12 14:00:00+00:00 | post | None | Crystal Palace | Southampton | 384 | 376 | CRY | SOU | 0.36979 | 0.35311 | 0.27710 | None | None | 1 | 0 | 1.05 | 0.000 | 1.507 | 1.160 | 0.943 | 1.652 | None | None |
2020-09-12 Fulham-Arsenal | 2020-09-12 11:30:00+00:00 | post | None | Fulham | Arsenal | 370 | 359 | FUL | ARS | 0.28167 | 0.46081 | 0.25752 | None | None | 0 | 3 | 0.00 | 3.150 | 0.141 | 2.989 | 0.270 | 1.528 | None | None | ||
2020-09-12 Liverpool-Leeds United | 2020-09-12 16:30:00+00:00 | post | None | Liverpool | Leeds United | 364 | 357 | LIV | LEE | 0.83582 | 0.04384 | 0.12034 | None | None | 4 | 3 | 4.20 | 3.150 | 3.328 | 0.368 | 3.006 | 0.747 | None | None | ||
2020-09-12 West Ham United-Newcastle | 2020-09-12 19:00:00+00:00 | post | None | West Ham United | Newcastle | 371 | 361 | WHU | NEW | 0.48865 | 0.25556 | 0.25579 | None | None | 0 | 2 | 0.00 | 1.666 | 0.973 | 1.475 | 1.103 | 1.860 | None | None | ||
2020-09-13 Tottenham Hotspur-Everton | 2020-09-13 15:30:00+00:00 | post | None | Tottenham Hotspur | Everton | 367 | 368 | TOT | EVE | 0.50235 | 0.24434 | 0.25331 | None | None | 0 | 1 | 0.00 | 1.050 | 1.029 | 1.109 | 1.316 | 1.110 | None | None |
Forecasted league table¶
[6]:
forecasts = five38.read_forecasts()
forecasts.head()
[6]:
code | current_losses | current_points | current_ties | current_wins | d_rating | global_d | global_o | global_rating | goal_diff | goals_against | goals_scored | id | losses | make_champs | make_europa | make_playoffs | o_rating | points | position_1 | position_10 | position_11 | position_12 | position_13 | position_14 | position_15 | position_16 | position_17 | position_18 | position_19 | position_2 | position_20 | position_3 | position_4 | position_5 | position_6 | position_7 | position_8 | position_9 | promoted | relegated | sdr_id | ties | win_league | wins | ||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
league | season | last_updated | team | |||||||||||||||||||||||||||||||||||||||||||||
ENG-Premier League | 2021 | 2020-09-09T14:46:49.136Z | Arsenal | ARS | 0.0 | 0.0 | 0.0 | 0.0 | 1.33114 | 0.68339 | 2.13421 | 77.16360 | 4.13260 | 49.72715 | 53.85975 | 359 | 13.27675 | 0.16095 | 0.0 | 0.0 | 1.48647 | 55.50395 | 0.00720 | 0.06905 | 0.06170 | 0.05220 | 0.04835 | 0.04075 | 0.03595 | 0.03045 | 0.02650 | 0.02035 | 0.01590 | 0.02725 | 0.01165 | 0.05280 | 0.07370 | 0.08895 | 0.09120 | 0.08990 | 0.08340 | 0.07275 | 0.0 | 0.04790 | 73616 | 9.3329 | 0.00720 | 15.39035 |
Aston Villa | AVL | 0.0 | 0.0 | 0.0 | 0.0 | 1.52263 | 0.87488 | 1.77744 | 66.48339 | -17.57325 | 57.65595 | 40.08270 | 362 | 17.72125 | 0.02335 | 0.0 | 0.0 | 1.12969 | 41.66985 | 0.00030 | 0.05405 | 0.06005 | 0.06500 | 0.06855 | 0.07090 | 0.07480 | 0.07685 | 0.07955 | 0.08465 | 0.08315 | 0.00315 | 0.08465 | 0.00615 | 0.01375 | 0.02105 | 0.02830 | 0.03375 | 0.04145 | 0.04990 | 0.0 | 0.25245 | 73597 | 9.5832 | 0.00030 | 10.69555 | |||
Brighton and Hove Albion | BHA | 0.0 | 0.0 | 0.0 | 0.0 | 1.45713 | 0.80938 | 1.77377 | 68.02657 | -15.24810 | 55.36300 | 40.11490 | 331 | 17.18525 | 0.02950 | 0.0 | 0.0 | 1.12603 | 42.92225 | 0.00075 | 0.05475 | 0.06255 | 0.06575 | 0.07025 | 0.07305 | 0.07485 | 0.07690 | 0.07505 | 0.07790 | 0.07590 | 0.00295 | 0.06700 | 0.00965 | 0.01615 | 0.02415 | 0.03275 | 0.04185 | 0.04450 | 0.05330 | 0.0 | 0.22080 | 73651 | 9.7610 | 0.00075 | 11.05375 | |||
Burnley | BRN | 0.0 | 0.0 | 0.0 | 0.0 | 1.41912 | 0.77137 | 1.77961 | 69.08173 | -13.63310 | 53.84085 | 40.20775 | 379 | 16.80205 | 0.03210 | 0.0 | 0.0 | 1.13187 | 43.86545 | 0.00100 | 0.05910 | 0.06525 | 0.06555 | 0.07245 | 0.06670 | 0.07370 | 0.07325 | 0.07340 | 0.07010 | 0.06735 | 0.00325 | 0.06145 | 0.01065 | 0.01720 | 0.02915 | 0.03935 | 0.04365 | 0.05110 | 0.05635 | 0.0 | 0.19890 | 73618 | 9.8642 | 0.00100 | 11.33375 | |||
Chelsea | CHE | 0.0 | 0.0 | 0.0 | 0.0 | 1.16934 | 0.52160 | 2.51615 | 85.37204 | 26.57990 | 42.20305 | 68.78295 | 363 | 9.34340 | 0.53090 | 0.0 | 0.0 | 1.86841 | 69.17900 | 0.06525 | 0.02775 | 0.02295 | 0.01715 | 0.01315 | 0.01000 | 0.00735 | 0.00585 | 0.00400 | 0.00230 | 0.00215 | 0.13860 | 0.00050 | 0.17560 | 0.15145 | 0.11230 | 0.08610 | 0.06630 | 0.04965 | 0.04160 | 0.0 | 0.00495 | 73598 | 8.3954 | 0.06525 | 20.26120 |
Clinches¶
[7]:
clinches = five38.read_clinches()
clinches.head()
[7]:
typ | team | |||
---|---|---|---|---|
league | season | date | ||
ENG-Premier League | 2021 | 2021-02-13 | relegated_elim | Manchester City |
2021-02-17 | win_league_elim | Sheffield United | ||
2021-02-17 | win_league_elim | West Bromwich Albion | ||
2021-02-27 | win_league_elim | Fulham | ||
2021-03-02 | win_league_elim | Newcastle |