Understat
[1]:
import sys
sys.path.append("../../")
import penaltyblog as pb
List available competitions
[2]:
pb.scrapers.Understat.list_competitions()
[2]:
['DEU Bundesliga 1',
'ENG Premier League',
'ESP La Liga',
'FRA Ligue 1',
'ITA Serie A',
'RUS Premier League']
Get Fixtures
[3]:
under = pb.scrapers.Understat("ENG Premier League", "2021-2022")
df = under.get_fixtures()
df.head()
[3]:
understat_id | datetime | team_home | team_away | goals_home | goals_away | xg_home | xg_away | forecast_w | forecast_d | forecast_l | season | competition | date | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | ||||||||||||||
1628812800---brentford---arsenal | 16376 | 2021-08-13 19:00:00 | Brentford | Arsenal | 2 | 0 | 1.888180 | 1.023850 | 0.6289 | 0.2287 | 0.1424 | 2021-2022 | ENG Premier League | 2021-08-13 |
1628899200---burnley---brighton | 16378 | 2021-08-14 14:00:00 | Burnley | Brighton | 1 | 2 | 1.795480 | 1.685300 | 0.3894 | 0.2877 | 0.3229 | 2021-2022 | ENG Premier League | 2021-08-14 |
1628899200---chelsea---crystal_palace | 16379 | 2021-08-14 14:00:00 | Chelsea | Crystal Palace | 3 | 0 | 1.187090 | 0.321701 | 0.6405 | 0.2822 | 0.0773 | 2021-2022 | ENG Premier League | 2021-08-14 |
1628899200---everton---southampton | 16380 | 2021-08-14 14:00:00 | Everton | Southampton | 3 | 1 | 2.388630 | 0.580601 | 0.8359 | 0.1234 | 0.0407 | 2021-2022 | ENG Premier League | 2021-08-14 |
1628899200---leicester---wolverhampton_wanderers | 16381 | 2021-08-14 14:00:00 | Leicester | Wolverhampton Wanderers | 1 | 0 | 0.668082 | 1.327140 | 0.1683 | 0.2750 | 0.5567 | 2021-2022 | ENG Premier League | 2021-08-14 |
Get shots from a specific match (using the understat_id
from the fixtures)
[4]:
shots = under.get_shots("16380")
shots.head()
[4]:
competition | season | datetime | minute | result | x | y | x_g | player | h_a | ... | situation | shot_type | match_id | team_home | team_away | goals_home | goals_away | date | player_assisted | last_action | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | |||||||||||||||||||||
1628899200---everton---southampton | ENG Premier League | 2021-2022 | 2021-08-14 14:00:00 | 2 | SavedShot | 0.8059999847412109 | 0.37099998474121093 | 0.034891288727521896 | Allan | h | ... | OpenPlay | RightFoot | 16380 | Everton | Southampton | 3 | 1 | 2021-08-14 | None | None |
1628899200---everton---southampton | ENG Premier League | 2021-2022 | 2021-08-14 14:00:00 | 9 | MissedShots | 0.9580000305175781 | 0.45799999237060546 | 0.111264169216156 | Dominic Calvert-Lewin | h | ... | OpenPlay | Head | 16380 | Everton | Southampton | 3 | 1 | 2021-08-14 | Demarai Gray | Aerial |
1628899200---everton---southampton | ENG Premier League | 2021-2022 | 2021-08-14 14:00:00 | 33 | BlockedShot | 0.784000015258789 | 0.40900001525878904 | 0.08816667646169662 | Lucas Digne | h | ... | DirectFreekick | LeftFoot | 16380 | Everton | Southampton | 3 | 1 | 2021-08-14 | None | Standard |
1628899200---everton---southampton | ENG Premier League | 2021-2022 | 2021-08-14 14:00:00 | 34 | MissedShots | 0.9409999847412109 | 0.5270000076293946 | 0.09325270354747772 | Dominic Calvert-Lewin | h | ... | OpenPlay | Head | 16380 | Everton | Southampton | 3 | 1 | 2021-08-14 | Andros Townsend | Cross |
1628899200---everton---southampton | ENG Premier League | 2021-2022 | 2021-08-14 14:00:00 | 43 | MissedShots | 0.774000015258789 | 0.645 | 0.01725037768483162 | Lucas Digne | h | ... | FromCorner | LeftFoot | 16380 | Everton | Southampton | 3 | 1 | 2021-08-14 | None | None |
5 rows × 21 columns
Get the other stats for the fixture
[5]:
info = under.get_fixture_info("16380")
info
[5]:
competition | season | datetime | fid | h | a | date | league_id | goals_home | goals_away | ... | h_l | league | shots_home | shots_away | shots_on_target_home | shots_on_target_away | deep_home | deep_away | ppda_away | ppda_home | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | |||||||||||||||||||||
1628899200---everton---southampton | ENG Premier League | 2021-2022 | 2021-08-14 14:00:00 | 1549542 | 72 | 74 | 2021-08-14 | 1 | 3 | 1 | ... | 0.0407 | EPL | 14 | 6 | 6 | 3 | 4 | 6 | 5.5926 | 6.8696 |
1 rows × 26 columns
Get the season for Erling Haaland
[6]:
player = under.get_player_season(8260)
player
[6]:
team | position | games | goals | shots | time | x_g | assists | x_a | key_passes | yellow | red | npg | npx_g | x_g_chain | x_g_buildup | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
season | ||||||||||||||||
2019 | Borussia Dortmund | Sub | 15 | 13 | 33 | 1061 | 8.889345575124025 | 2 | 1.5264748334884644 | 9 | 0 | 0 | 13 | 8.889345575124025 | 11.366184580139816 | 2.9849864905700088 |
2020 | Borussia Dortmund | FW | 28 | 27 | 92 | 2416 | 23.598482109606266 | 6 | 4.035449907183647 | 27 | 2 | 0 | 25 | 20.567375369369984 | 27.197274826467037 | 5.896184146404266 |
2021 | Borussia Dortmund | FW | 24 | 22 | 80 | 1917 | 17.03095668926835 | 7 | 5.89400115981698 | 23 | 3 | 0 | 16 | 12.484377015382051 | 19.772439118474722 | 4.2647324707359076 |
2022 | Manchester City | FW | 1 | 2 | 5 | 82 | 2.1663577556610107 | 0 | 0 | 0 | 0 | 0 | 1 | 1.405188798904419 | 1.5119959115982056 | 0.10680713504552841 |
Get all Erling Haaland’s shots
[7]:
shots = under.get_player_shots(8260)
shots
[7]:
minute | result | x | y | x_g | player | h_a | understat_player_id | situation | season | ... | understat_fixture_id | team_home | team_away | goals_home | goals_away | date | player_assisted | last_action | datetime | id | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
understat_shot_id | |||||||||||||||||||||
354876 | 58 | Goal | 0.8880000305175781 | 0.6659999847412109 | 0.07933320105075836 | Erling Haaland | a | 8260 | OpenPlay | 2019 | ... | 12562 | Augsburg | Borussia Dortmund | 3 | 5 | 2020-01-18 | Jadon Sancho | Throughball | 2020-01-18 14:30:00 | 1579305600---augsburg---borussia_dortmund |
354881 | 69 | Goal | 0.98 | 0.48900001525878906 | 0.9206209778785706 | Erling Haaland | a | 8260 | OpenPlay | 2019 | ... | 12562 | Augsburg | Borussia Dortmund | 3 | 5 | 2020-01-18 | Thorgan Hazard | Pass | 2020-01-18 14:30:00 | 1579305600---augsburg---borussia_dortmund |
354883 | 78 | Goal | 0.8830000305175781 | 0.34700000762939454 | 0.3228312134742737 | Erling Haaland | a | 8260 | OpenPlay | 2019 | ... | 12562 | Augsburg | Borussia Dortmund | 3 | 5 | 2020-01-18 | Marco Reus | Throughball | 2020-01-18 14:30:00 | 1579305600---augsburg---borussia_dortmund |
355527 | 65 | BlockedShot | 0.8859999847412109 | 0.639000015258789 | 0.1191810667514801 | Erling Haaland | h | 8260 | OpenPlay | 2019 | ... | 12566 | Borussia Dortmund | FC Cologne | 5 | 1 | 2020-01-24 | Jadon Sancho | Pass | 2020-01-24 19:30:00 | 1579824000---borussia_dortmund---fc_cologne |
355531 | 76 | Goal | 0.955 | 0.495 | 0.746640682220459 | Erling Haaland | h | 8260 | OpenPlay | 2019 | ... | 12566 | Borussia Dortmund | FC Cologne | 5 | 1 | 2020-01-24 | None | Rebound | 2020-01-24 19:30:00 | 1579824000---borussia_dortmund---fc_cologne |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
479846 | 20 | MissedShots | 0.9359999847412109 | 0.5029999923706054 | 0.48408451676368713 | Erling Haaland | a | 8260 | OpenPlay | 2022 | ... | 18211 | West Ham | Manchester City | 0 | 2 | 2022-08-07 | Phil Foden | Cross | 2022-08-07 15:30:00 | 1659830400---west_ham---manchester_city |
479847 | 35 | Goal | 0.885 | 0.5 | 0.7611688375473022 | Erling Haaland | a | 8260 | Penalty | 2022 | ... | 18211 | West Ham | Manchester City | 0 | 2 | 2022-08-07 | None | Standard | 2022-08-07 15:30:00 | 1659830400---west_ham---manchester_city |
479854 | 64 | Goal | 0.8640000152587891 | 0.405 | 0.3280530571937561 | Erling Haaland | a | 8260 | OpenPlay | 2022 | ... | 18211 | West Ham | Manchester City | 0 | 2 | 2022-08-07 | Kevin De Bruyne | Throughball | 2022-08-07 15:30:00 | 1659830400---west_ham---manchester_city |
479855 | 69 | MissedShots | 0.9530000305175781 | 0.5520000076293945 | 0.5266084671020508 | Erling Haaland | a | 8260 | OpenPlay | 2022 | ... | 18211 | West Ham | Manchester City | 0 | 2 | 2022-08-07 | Jack Grealish | Chipped | 2022-08-07 15:30:00 | 1659830400---west_ham---manchester_city |
479856 | 75 | BlockedShot | 0.894000015258789 | 0.71 | 0.06644278019666672 | Erling Haaland | a | 8260 | OpenPlay | 2022 | ... | 18211 | West Ham | Manchester City | 0 | 2 | 2022-08-07 | Ilkay Gündogan | Pass | 2022-08-07 15:30:00 | 1659830400---west_ham---manchester_city |
210 rows × 21 columns
[ ]: