Skip to main content

pull sports stats

Project description

WORK IN PROGRESS

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 (Pandas DataFrame)

from sportrefpy.nba.player import NBAPlayer

# For all stats
king = NBAPlayer('LeBron James')
king.career_totals()

# For a specific stat
beard = NBAPlayer('James Harden')
beard.career_totals()['PTS']

Compare players stat totals (Pandas DataFrame)

from sportrefpy.nba.analysis import compare_players

showtime = compare_players(["Shaquille O'Neal", "Kobe Bryant"], 
                            stats=['PTS', 'GS']
                            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 (Pandas DataFrame)

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 (Pandas DataFrame)

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 (Pandas DataFrame)

from sportrefpy.nba.team import NBAFranchise

warriors = NBAFranchise('GSW')
warriors.roster(2016)
  • use the integer for the year the season ends in. This example returns the 2015-16 Golden State Warriors.

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

sportrefpy-0.1.2.tar.gz (41.5 kB view details)

Uploaded Source

Built Distribution

sportrefpy-0.1.2-py2.py3-none-any.whl (47.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file sportrefpy-0.1.2.tar.gz.

File metadata

  • Download URL: sportrefpy-0.1.2.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

Hashes for sportrefpy-0.1.2.tar.gz
Algorithm Hash digest
SHA256 23a3f2b4b965984dec325de7d6354b2baf3770751102f296b9b045ce17830619
MD5 df3fabca9e66c46ab7d83ddc74bb03cb
BLAKE2b-256 19bade52dc750ab3d840a40b49d0d8b5e323ed4ddc536601ad92c2ce13eb6989

See more details on using hashes here.

File details

Details for the file sportrefpy-0.1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: sportrefpy-0.1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 47.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.6

File hashes

Hashes for sportrefpy-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 28b8f53a92c0a0b71e742b2aa4e7b9a1131045f8a497f551bc306e77f9a1a5ee
MD5 328740ad6f2a47640b3db9480d38705d
BLAKE2b-256 15d0e00aea40c9e3e15ff43277bc83de401a98717cd1e5bdaa0a99768e85ffa5

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