Package: nba-history
nba_historyis a python package for dynamically scraping NBA player, team, and draft data.All nba_history functions return scraped data as apandas dataframewith an option to also export toCSV.Examplefromnba_historyimportplayer_data,team_data# scrape 2013 NBA draft picksdf=player_data.scrape_draft_data(start_year=2013,end_year=2013,export=False)print(df.head())Installationnba_history depends on the Python modulesrequests,beautifulsoup, andpandasInstallation with pip:if you havepipinstalled, type this in a terminal:$python-mpipinstallnba_historyInstallation by hand:download the sources, either fromPyPIor, if you want the development version, fromGitHub, unzip everything into one folder, open a terminal and type:$(sudo)pythonsetup.cfginstallDocumentationThe nba_history package has 2 modules,player_dataandteam_dataList of all functions in player_data modulescrape_draft_dataScrape NBA draft data by year, including:draft rounddraft pick numbercollegeyears in the NBAand much more..function argumentsstart_year: first year to scrapeend_year: last year to scrapeexport: option to export to CSV. Default is set asTruefromnba_historyimportplayer_data# scrape 2017-2020 NBA draft picksdf=player_data.scrape_draft_data(start_year=2017,end_year=2020,export=True)scrape_player_salariesScrape NBA player salary by year, including:League RankPlayerSalaryfunction argumentsstart_year: first year to scrapeend_year: last year to scrapeexport: option to export to CSV. Default is set asTruesleep_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.fromnba_historyimportplayer_data# scrape 2001-2003 player salariesdf=player_data.scrape_player_salaries(start_year=2001,end_year=2003,export=True,sleep_time=2)scrape_player_total_statsScrape NBA player total stats by year, including:PointsReboundsAssistsMinutesGames3PAand much more..function arguments:
function argumentsstart_year: first year to scrapeend_year: last year to scrapeexport: option to export to CSV. Default is set asTruesleep_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.fromnba_historyimportplayer_data# scrape 2011-2015 player total statsdf=player_data.scrape_player_total_stats(start_year=2011,end_year=2015,export=True,sleep_time=2)scrape_player_per_game_statsScrape NBA player per game stats by year, including:PointsReboundsFG%Minutes3P%and much more..function argumentsstart_year: first year to scrapeend_year: last year to scrapeexport: option to export to CSV. Default is set asTruesleep_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.fromnba_historyimportplayer_data# scrape 2000-2009 player per game statsdf=player_data.scrape_player_per_game_stats(start_year=2000,end_year=2009,export=True,sleep_time=2)scrape_player_advanced_statsScrape NBA player advanced stats by year, including:PERWSORB%3PArand much more..function argumentsstart_year: first year to scrapeend_year: last year to scrapeexport: option to export to CSV. Default is set asTruesleep_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.fromnba_historyimportplayer_data# scrape 1998-2001 advanced statsdf=player_data.scrape_player_advanced_stats(start_year=1998,end_year=2001,export=True,sleep_time=2)scrape_player_shooting_statsScrape NBA player shooting stats by year, including:DunksFG% by distance% of FG by distanceCorner 3PT%and much more..function argumentsstart_year: first year to scrapeend_year: last year to scrapeexport: option to export to CSV. Default is set asTruesleep_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.fromnba_historyimportplayer_data# scrape 1980-1985 player shooting statsdf=player_data.scrape_player_shooting_stats(start_year=1980,end_year=1985,export=True,sleep_time=2)scrape_all_starsScrape all NBA All-Stars for alltime, including:Hall of Fame statusAll Star appearancesand more..function arguments:export: option to export to CSV. Default is set asTruefromnba_historyimportplayer_data# scrape all NBA All-Stars alltimedf=player_data.scrape_all_stars(export=True)List of all functions in team_data modulescrape_nba_team_recordsScrape NBA team records by year, including:Playoff appearanceWinsLossesPPGand much more..function argumentsstart_year: first year to scrapeend_year: last year to scrapeexport: option to export to CSV. Default is set asTruefromnba_historyimportteam_data# scrape 2010-2018 player per game statsdf=team_data.scrape_nba_team_records(start_year=2010,end_year=2018,export=True)Contributenba_history is open-source library originally written byodonnell31and released under the MIT licence. The project is hosted onGitHub, where everyone is welcome to contribute, ask for help or simply give feedback.Maintainers@odonnell31(owner)