Skip to main content

Repository for rugby data analytics

Project description

rugbypy

rugbypy is a Python package that aims to make rugby data more available to aid in the development of rugby analytics. Currently we only have 2023 data available with previous years coming soon!

PyPI - Downloads

Requirements

python version 3.8

Install

pip install rugbypy

How to use

Match Stats

You can fetch all the matches that occured on a particular date with:

matches = fetch_matches(date="20230101")
matches
Fetching matches on date:20230101...
match_id competition_id home_team_id away_team_id date
0 595735 267979 25907 25901 20230101

Then using that match id you can feed it into the match details function:

match_details = fetch_match_details(match_id="595735")
match_details
Fetching match details for match_id:595735...
match_id date competition_id competition venue_id venue city_played home_team away_team home_team_id away_team_id completed is_tournament played_on_grass attendance home_team_form away_team_form
0 595735 20230101 267979 Premiership Rugby 26070 cinch Stadium at Franklin's Gardens Northampton Northampton Saints Harlequins 25907 25901 True True True None LLWWL WLWLL

Team Stats

You can then fetch the team stats for a particular team on a particular date with:

team_stats = fetch_team_stats(team_id="25901", date="20230108")
team_stats
Fetching team stats for team_id:25901 on date:20230108...
team game_date team_id team_vs team_vs_id clean_breaks conversion_goals defenders_beaten kick_percent_success kicks ... scrums_total scrums_won tackles territory total_free_kicks_conceded total_lineouts tries turnover_knock_on turnovers_conceded yellow_cards
0 Harlequins 20230108 25901 Sale Sharks 25908 3.0 0.0 24.0 0.5 0.0 ... 7.0 5.0 125.0 0.41 0.0 11.0 2.0 8.0 17.0 0.0

1 rows × 40 columns

Player Stats

We have the ability to fetch player stats for all the games they have bene involved in. We firstly identify the `player_id`` of a player by searching our player manifest file.

player_manifest = fetch_all_players()
player_manifest.head()
player_id player_name
0 246815 Will Edwards
1 158708 Tommaso Allan
2 299436 Oscar Beard
3 299031 Fin Baxter
4 298485 Jordan Els

Or we can search for a certain player through our similarity tool:

individual_player = fetch_player(name="johnny sexton")
individual_player
player_id player_name
267 149315 Anthony Watson
294 16004 Johnny Sexton
796 291349 Ayden Johnstone

We can also fetch the player stats for any player using their player_ids. In this example we fetch Johnny Sextons player stats:

player_stats = fetch_player_stats(player_id="16004")
player_stats
Fetching all player stats for player_id:16004...
player_id game_date name team team_id competition_id competition team_vs team_vs_id weight ... rucks_won runs tackles total_free_kicks_conceded total_lineouts tries try_assists turnover_knock_on turnovers_conceded yellow_cards
0 16004 20230204 Johnny Sexton Ireland 3 180659 Six Nations Championship 4 Wales 92.0 ... 3.0 8.0 7.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0
0 16004 20230211 Johnny Sexton Ireland 3 180659 Six Nations Championship 9 France 92.0 ... 1.0 5.0 3.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0 16004 20230312 Johnny Sexton Ireland 3 180659 Six Nations Championship 2 Scotland 92.0 ... 2.0 5.0 9.0 0.0 0.0 0.0 0.0 0.0 2.0 0.0
0 16004 20230318 Johnny Sexton Ireland 3 180659 Six Nations Championship 1 England 92.0 ... 6.0 9.0 5.0 0.0 0.0 0.0 0.0 1.0 2.0 0.0
0 16004 20230909 Johnny Sexton Ireland 3 164205 Rugby World Cup 12 Romania 92.0 ... 0.0 5.0 4.0 0.0 0.0 2.0 0.0 0.0 0.0 0.0
0 16004 20230916 Johnny Sexton Ireland 3 164205 Rugby World Cup 16 Tonga 92.0 ... 1.0 1.0 2.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0

6 rows × 40 columns

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rugbypy-1.0.0.tar.gz (14.3 kB view hashes)

Uploaded Source

Built Distribution

rugbypy-1.0.0-py3-none-any.whl (11.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page