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.

PyPI - Downloads

Requirements

python version 3.8

Install

pip install rugbypy
conda install -c seanyboi 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 dates 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 can also fetch the player stats for any player using their player_ids. In this example we fetch Billy Twelvetrees in game stats:

player_stats = fetch_player_stats(player_id="102049")
player_stats
Fetching all player stats for player_id:102049...
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 102049 20230106 Billy Twelvetrees Gloucester Rugby 25900 267979 Premiership Rugby 25909 Saracens 101.0 ... 0.0 0.0 2.0 0.0 0.0 0.0 0.0 1.0 1.0 0.0
0 102049 20230128 Billy Twelvetrees Gloucester Rugby 25900 267979 Premiership Rugby 116227 Exeter Chiefs 101.0 ... 3.0 2.0 15.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0
0 102049 20230225 Billy Twelvetrees Gloucester Rugby 25900 267979 Premiership Rugby 25907 Northampton Saints 101.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 0.0
0 102049 20230312 Billy Twelvetrees Gloucester Rugby 25900 267979 Premiership Rugby 25903 Leicester Tigers 101.0 ... 0.0 0.0 4.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0 102049 20230324 Billy Twelvetrees Gloucester Rugby 25900 267979 Premiership Rugby 25906 Newcastle Falcons 101.0 ... 0.0 0.0 4.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0 102049 20230414 Billy Twelvetrees Gloucester Rugby 25900 267979 Premiership Rugby 25898 Bath Rugby 101.0 ... 1.0 2.0 9.0 0.0 0.0 0.0 0.0 1.0 2.0 0.0
0 102049 20230422 Billy Twelvetrees Gloucester Rugby 25900 267979 Premiership Rugby 25908 Sale Sharks 101.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 0.0
0 102049 20230506 Billy Twelvetrees Gloucester Rugby 25900 267979 Premiership Rugby 25899 Bristol Rugby 101.0 ... 0.0 1.0 5.0 0.0 0.0 0.0 0.0 2.0 1.0 0.0

8 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-0.0.3.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

rugbypy-0.0.3-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file rugbypy-0.0.3.tar.gz.

File metadata

  • Download URL: rugbypy-0.0.3.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.13

File hashes

Hashes for rugbypy-0.0.3.tar.gz
Algorithm Hash digest
SHA256 e0003f40d260d916dd944112b6be60372d3ad94edb76df4775aa68cfffcb7ed1
MD5 1b4dc445836ae637cbba96c42f77be89
BLAKE2b-256 a7662ce3ebe708819e8484aefaf3d3493a7e4be22ed911f6fd45050e524bd91c

See more details on using hashes here.

File details

Details for the file rugbypy-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: rugbypy-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.13

File hashes

Hashes for rugbypy-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f81fa010077823126c04d17e9fa034a059e0bfc1638fcc657a3b0843f55e1077
MD5 2fe03055e63c7061134b906e9091f82f
BLAKE2b-256 dcb94df227dc7435ea78aafd959d459687cca192de8fe0ae605cd97d208b3640

See more details on using hashes here.

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