pull sports stats
Project description
SPORTREFPY
Sportrefpy is package that pulls data from the Sports-Reference family of sites. Currently, only NBA is working but NHL, NFL, MLB, and College Basketball and Football will be supported as soon as possible.
Installation
pip install sportrefpy
Usage
Below are some examples for ways that you can use Sports Stats.
Initialize a league, team, and player
from sportrefpy.nba.league import NBA
from sportrefpy.nba.team import NBAFranchise
from sportrefpy.nba.player import NBAPlayer
nba = NBA()
phi = NBAFranchise('PHI')
the_answer = NBAPlayer('Allen Iverson')
Print out Franchise Codes (needed for initializing a team)
from sportrefpy.nba.league import NBA
nba = NBA()
nba.franchise_codes()
Find the career totals (regular + playoffs) of a specific player
from sportrefpy.nba.player import NBAPlayer
# For all stats
king = NBAPlayer('LeBron James')
king.career_totals()
# For a specific stats
beard = NBAPlayer('James Harden')
beard.career_totals(stats=['PTS', 'G'])
- stats is None by default. If provide, it must be a list even if only using 1.
Compare players stat totals
from sportrefpy.nba.analysis import compare_players
showtime = compare_players(["Shaquille O'Neal", "Kobe Bryant"],
stats=['PTS', 'TRB'],
total='career')
- stats must be a list, with as many stats as you'd like. Required.
- total defaults to 'career', but can also be 'post' or 'reg'.
Compare Franchise W/L records
from sportrefpy.nba.analysis import compare_franchises
compare_franchises(['NYK', 'BOS'])
- must be a list of teams, even if only using 1.
Get stats of players/coaches for a specific Franchise
from sportrefpy.nba.team import NBAFranchise
# Players
bulls = NBAFranchise('CHI')
# All players that have ever played for the team
bulls.players_all_time_stats()
# Or just the GOAT
bulls.players_all_time_stats('Michael Jordan')
# Coaches
spurs = NBAFranchise('SAS')
# All coaches that have ever coached the team
spurs.coaches_all_time_data()
# Or just Pop
spurs.coaches_all_time_data('Gregg Popovich')
Get roster for a given season
from sportrefpy.nba.team import NBAFranchise
warriors = NBAFranchise('GSW')
warriors.roster(2016)
- use integer year that season ends in. This example returns the 2015-16 Golden State Warriors.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sportrefpy-0.1.8.tar.gz
(41.5 kB
view details)
Built Distribution
File details
Details for the file sportrefpy-0.1.8.tar.gz
.
File metadata
- Download URL: sportrefpy-0.1.8.tar.gz
- Upload date:
- Size: 41.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f29e272d07f1bdc5268c363e34490a50cd14d9888f050f3ee276890265ac673b |
|
MD5 | 601bab68ca18956d80034a1196ed51ec |
|
BLAKE2b-256 | 3459aca1c7f9e5082411368a05cd60e559c5305b86815e1967e45d68902d2573 |
File details
Details for the file sportrefpy-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: sportrefpy-0.1.8-py3-none-any.whl
- Upload date:
- Size: 47.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe41df5fe1a60bc7d78d460c36ccff852257fdb0d7b472a756ff3bf16f8eb0c2 |
|
MD5 | 9a663188adcfaa1bb916470580936337 |
|
BLAKE2b-256 | 6e77a7e051207becc2aef3ab93677e089f609dea0c888466f60d64770c126a0b |