Skip to main content

No project description provided

Project description

Alt text

Version Downloads Coverage

nba_history is a python package for dynamically scraping NBA player, team, and draft data.

All nba_history functions return scraped data as a pandas dataframe with an option to also export to CSV.

Example

from nba_history import player_data, team_data

# scrape 2013 NBA draft picks
df = player_data.scrape_draft_data(start_year = 2013,
	end_year = 2013,
	export = False)
	
print(df.head())

Alt text

Installation

nba_history depends on the Python modules requests, beautifulsoup, and pandas

Installation with pip: if you have pip installed, type this in a terminal:

$ python -m pip install nba_history

Installation by hand: download the sources, either from PyPI or, if you want the development version, from GitHub, unzip everything into one folder, open a terminal and type:

$ (sudo) python setup.cfg install

Documentation

The nba_history package has 2 modules, player_data and team_data

List of all functions in player_data module

scrape_draft_data

Scrape NBA draft data by year, including:

  • draft round
  • draft pick number
  • college
  • years in the NBA
  • and much more..

function arguments

  • start_year: first year to scrape
  • end_year: last year to scrape
  • export: option to export to CSV. Default is set as True
from nba_history import player_data

# scrape 2017-2020 NBA draft picks
df = player_data.scrape_draft_data(start_year = 2017,
	end_year = 2020,
	export = True)

scrape_player_salaries

Scrape NBA player salary by year, including:

  • League Rank
  • Player
  • Salary

function arguments

  • start_year: first year to scrape
  • end_year: last year to scrape
  • export: option to export to CSV. Default is set as True
  • sleep_time: time to pause function between sraping each year. Default is set as 2 seconds, if scraping >10 years then changing to 1 second is recommended.
from nba_history import player_data

# scrape 2001-2003 player salaries
df = player_data.scrape_player_salaries(start_year = 2001,
	end_year = 2003,
	export = True,
	sleep_time = 2)

scrape_player_total_stats

Scrape NBA player total stats by year, including:

  • Points
  • Rebounds
  • Assists
  • Minutes
  • Games
  • 3PA
  • and much more..

function arguments: function arguments

  • start_year: first year to scrape
  • end_year: last year to scrape
  • export: option to export to CSV. Default is set as True
  • sleep_time: time to pause function between sraping each year. Default is set as 2 seconds, if scraping >10 years then changing to 1 second is recommended.
from nba_history import player_data

# scrape 2011-2015 player total stats
df = player_data.scrape_player_total_stats(start_year = 2011,
	end_year = 2015,
	export = True,
	sleep_time = 2)

scrape_player_per_game_stats

Scrape NBA player per game stats by year, including:

  • Points
  • Rebounds
  • FG%
  • Minutes
  • 3P%
  • and much more..

function arguments

  • start_year: first year to scrape
  • end_year: last year to scrape
  • export: option to export to CSV. Default is set as True
  • sleep_time: time to pause function between sraping each year. Default is set as 2 seconds, if scraping >10 years then changing to 1 second is recommended.
from nba_history import player_data

# scrape 2000-2009 player per game stats
df = player_data.scrape_player_per_game_stats(start_year = 2000,
	end_year = 2009,
	export = True,
	sleep_time = 2)

scrape_player_advanced_stats

Scrape NBA player advanced stats by year, including:

  • PER
  • WS
  • ORB%
  • 3PAr
  • and much more..

function arguments

  • start_year: first year to scrape
  • end_year: last year to scrape
  • export: option to export to CSV. Default is set as True
  • sleep_time: time to pause function between sraping each year. Default is set as 2 seconds, if scraping >10 years then changing to 1 second is recommended.
from nba_history import player_data

# scrape 1998-2001 advanced stats
df = player_data.scrape_player_advanced_stats(start_year = 1998,
	end_year = 2001,
	export = True,
	sleep_time = 2)

scrape_player_shooting_stats

Scrape NBA player shooting stats by year, including:

  • Dunks
  • FG% by distance
  • % of FG by distance
  • Corner 3PT%
  • and much more..

function arguments

  • start_year: first year to scrape
  • end_year: last year to scrape
  • export: option to export to CSV. Default is set as True
  • sleep_time: time to pause function between sraping each year. Default is set as 2 seconds, if scraping >10 years then changing to 1 second is recommended.
from nba_history import player_data

# scrape 1980-1985 player shooting stats
df = player_data.scrape_player_shooting_stats(start_year = 1980,
	end_year = 1985,
	export = True,
	sleep_time = 2)

scrape_all_stars

Scrape all NBA All-Stars for alltime, including:

  • Hall of Fame status
  • All Star appearances
  • and more..

function arguments:

  • export: option to export to CSV. Default is set as True
from nba_history import player_data

# scrape all NBA All-Stars alltime
df = player_data.scrape_all_stars(export = True)

List of all functions in team_data module

scrape_nba_team_records

Scrape NBA team records by year, including:

  • Playoff appearance
  • Wins
  • Losses
  • PPG
  • and much more..

function arguments

  • start_year: first year to scrape
  • end_year: last year to scrape
  • export: option to export to CSV. Default is set as True
from nba_history import team_data

# scrape 2010-2018 player per game stats
df = team_data.scrape_nba_team_records(start_year = 2010,
	end_year = 2018,
	export = True)

Contribute

nba_history is open-source library originally written by odonnell31 and released under the MIT licence. The project is hosted on GitHub, where everyone is welcome to contribute, ask for help or simply give feedback.

Maintainers

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

nba_history-1.1.7.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nba_history-1.1.7-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file nba_history-1.1.7.tar.gz.

File metadata

  • Download URL: nba_history-1.1.7.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/0.19 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2

File hashes

Hashes for nba_history-1.1.7.tar.gz
Algorithm Hash digest
SHA256 a61a9574df5737307800b5deeb0c77abeb8900a5aceedfc24e3d3c6bec41f5b5
MD5 b82f1f3ac4e7032791ec4d887bbe997b
BLAKE2b-256 af17d33e30f5ef2ae93ad505af264bddcaa7bba3aa5e16fbc8300b9ad8cf6ed6

See more details on using hashes here.

File details

Details for the file nba_history-1.1.7-py3-none-any.whl.

File metadata

  • Download URL: nba_history-1.1.7-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/0.19 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2

File hashes

Hashes for nba_history-1.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 021c03428f10ec442d86a0dab5d7328b9cf298bb058e6ef8849418a4589389dc
MD5 ec86c66ec336c6d546c5fb7a969e034e
BLAKE2b-256 1007028ffbec37473ff0eba7b3459442e0e796e45b444385f63f81efe9ea14ab

See more details on using hashes here.

Supported by

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