diff --git a/.tox/log/GLOB-0.log b/.tox/log/GLOB-0.log index ebb9dca..54192c0 100644 --- a/.tox/log/GLOB-0.log +++ b/.tox/log/GLOB-0.log @@ -8,126 +8,121 @@ writing dependency_links to nfl_data_py.egg-info\dependency_links.txt writing requirements to nfl_data_py.egg-info\requires.txt writing top-level names to nfl_data_py.egg-info\top_level.txt reading manifest file 'nfl_data_py.egg-info\SOURCES.txt' -reading manifest template 'MANIFEST.in' writing manifest file 'nfl_data_py.egg-info\SOURCES.txt' running check -creating nfl_data_py-0.2.9 -creating nfl_data_py-0.2.9\data -creating nfl_data_py-0.2.9\data\schedules -creating nfl_data_py-0.2.9\nfl_data_py -creating nfl_data_py-0.2.9\nfl_data_py.egg-info -creating nfl_data_py-0.2.9\nfl_data_py\tests -creating nfl_data_py-0.2.9\nfl_data_py\tests\__pycache__ -copying files to nfl_data_py-0.2.9... -copying CHANGELOG.md -> nfl_data_py-0.2.9 -copying CONTRIBUTING.md -> nfl_data_py-0.2.9 -copying LICENSE -> nfl_data_py-0.2.9 -copying MANIFEST.in -> nfl_data_py-0.2.9 -copying README.md -> nfl_data_py-0.2.9 -copying code_of_conduct.md -> nfl_data_py-0.2.9 -copying constraints.txt -> nfl_data_py-0.2.9 -copying setup.py -> nfl_data_py-0.2.9 -copying tox.ini -> nfl_data_py-0.2.9 -copying data\coaching_history.csv -> nfl_data_py-0.2.9\data -copying data\combine.csv -> nfl_data_py-0.2.9\data -copying data\drafts.csv -> nfl_data_py-0.2.9\data -copying data\qbr.csv -> nfl_data_py-0.2.9\data -copying data\schedules\1999.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2000.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2001.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2002.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2003.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2004.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2005.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2006.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2007.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2008.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2009.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2010.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2011.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2012.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2013.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2014.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2015.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2016.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2017.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2018.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2019.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2020.csv -> nfl_data_py-0.2.9\data\schedules -copying data\schedules\2021.csv -> nfl_data_py-0.2.9\data\schedules -copying nfl_data_py\__init__.py -> nfl_data_py-0.2.9\nfl_data_py -copying nfl_data_py.egg-info\PKG-INFO -> nfl_data_py-0.2.9\nfl_data_py.egg-info -copying nfl_data_py.egg-info\SOURCES.txt -> nfl_data_py-0.2.9\nfl_data_py.egg-info -copying nfl_data_py.egg-info\dependency_links.txt -> nfl_data_py-0.2.9\nfl_data_py.egg-info -copying nfl_data_py.egg-info\requires.txt -> nfl_data_py-0.2.9\nfl_data_py.egg-info -copying nfl_data_py.egg-info\top_level.txt -> nfl_data_py-0.2.9\nfl_data_py.egg-info -copying nfl_data_py\tests\nfl_test.py -> nfl_data_py-0.2.9\nfl_data_py\tests -copying nfl_data_py\tests\__pycache__\nfl_test.cpython-35-pytest-6.1.2.pyc -> nfl_data_py-0.2.9\nfl_data_py\tests\__pycache__ -copying nfl_data_py\tests\__pycache__\nfl_test.cpython-37-pytest-6.2.4.pyc -> nfl_data_py-0.2.9\nfl_data_py\tests\__pycache__ -copying nfl_data_py\tests\__pycache__\nfl_test.cpython-37-pytest-7.1.0.pyc -> nfl_data_py-0.2.9\nfl_data_py\tests\__pycache__ -copying nfl_data_py\tests\__pycache__\nfl_test.cpython-37-pytest-7.1.2.pyc -> nfl_data_py-0.2.9\nfl_data_py\tests\__pycache__ -copying nfl_data_py\tests\__pycache__\nfl_test.cpython-39-pytest-6.2.4.pyc -> nfl_data_py-0.2.9\nfl_data_py\tests\__pycache__ -copying nfl_data_py\tests\__pycache__\nfl_test.cpython-39-pytest-6.2.5.pyc -> nfl_data_py-0.2.9\nfl_data_py\tests\__pycache__ -copying nfl_data_py\tests\__pycache__\nfl_test.cpython-39-pytest-7.1.2.pyc -> nfl_data_py-0.2.9\nfl_data_py\tests\__pycache__ -Writing nfl_data_py-0.2.9\setup.cfg -creating '.tox\dist\nfl_data_py-0.2.9.zip' and adding 'nfl_data_py-0.2.9' to it -adding 'nfl_data_py-0.2.9' -adding 'nfl_data_py-0.2.9\data' -adding 'nfl_data_py-0.2.9\nfl_data_py' -adding 'nfl_data_py-0.2.9\nfl_data_py.egg-info' -adding 'nfl_data_py-0.2.9\CHANGELOG.md' -adding 'nfl_data_py-0.2.9\code_of_conduct.md' -adding 'nfl_data_py-0.2.9\constraints.txt' -adding 'nfl_data_py-0.2.9\CONTRIBUTING.md' -adding 'nfl_data_py-0.2.9\LICENSE' -adding 'nfl_data_py-0.2.9\MANIFEST.in' -adding 'nfl_data_py-0.2.9\PKG-INFO' -adding 'nfl_data_py-0.2.9\README.md' -adding 'nfl_data_py-0.2.9\setup.cfg' -adding 'nfl_data_py-0.2.9\setup.py' -adding 'nfl_data_py-0.2.9\tox.ini' -adding 'nfl_data_py-0.2.9\data\schedules' -adding 'nfl_data_py-0.2.9\data\coaching_history.csv' -adding 'nfl_data_py-0.2.9\data\combine.csv' -adding 'nfl_data_py-0.2.9\data\drafts.csv' -adding 'nfl_data_py-0.2.9\data\qbr.csv' -adding 'nfl_data_py-0.2.9\data\schedules\1999.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2000.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2001.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2002.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2003.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2004.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2005.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2006.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2007.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2008.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2009.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2010.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2011.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2012.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2013.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2014.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2015.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2016.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2017.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2018.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2019.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2020.csv' -adding 'nfl_data_py-0.2.9\data\schedules\2021.csv' -adding 'nfl_data_py-0.2.9\nfl_data_py\tests' -adding 'nfl_data_py-0.2.9\nfl_data_py\__init__.py' -adding 'nfl_data_py-0.2.9\nfl_data_py\tests\__pycache__' -adding 'nfl_data_py-0.2.9\nfl_data_py\tests\nfl_test.py' -adding 'nfl_data_py-0.2.9\nfl_data_py\tests\__pycache__\nfl_test.cpython-35-pytest-6.1.2.pyc' -adding 'nfl_data_py-0.2.9\nfl_data_py\tests\__pycache__\nfl_test.cpython-37-pytest-6.2.4.pyc' -adding 'nfl_data_py-0.2.9\nfl_data_py\tests\__pycache__\nfl_test.cpython-37-pytest-7.1.0.pyc' -adding 'nfl_data_py-0.2.9\nfl_data_py\tests\__pycache__\nfl_test.cpython-37-pytest-7.1.2.pyc' -adding 'nfl_data_py-0.2.9\nfl_data_py\tests\__pycache__\nfl_test.cpython-39-pytest-6.2.4.pyc' -adding 'nfl_data_py-0.2.9\nfl_data_py\tests\__pycache__\nfl_test.cpython-39-pytest-6.2.5.pyc' -adding 'nfl_data_py-0.2.9\nfl_data_py\tests\__pycache__\nfl_test.cpython-39-pytest-7.1.2.pyc' -adding 'nfl_data_py-0.2.9\nfl_data_py.egg-info\dependency_links.txt' -adding 'nfl_data_py-0.2.9\nfl_data_py.egg-info\PKG-INFO' -adding 'nfl_data_py-0.2.9\nfl_data_py.egg-info\requires.txt' -adding 'nfl_data_py-0.2.9\nfl_data_py.egg-info\SOURCES.txt' -adding 'nfl_data_py-0.2.9\nfl_data_py.egg-info\top_level.txt' -removing 'nfl_data_py-0.2.9' (and everything under it) +creating nfl_data_py-0.3.0 +creating nfl_data_py-0.3.0\data +creating nfl_data_py-0.3.0\data\schedules +creating nfl_data_py-0.3.0\nfl_data_py +creating nfl_data_py-0.3.0\nfl_data_py.egg-info +creating nfl_data_py-0.3.0\nfl_data_py\tests +creating nfl_data_py-0.3.0\nfl_data_py\tests\__pycache__ +copying files to nfl_data_py-0.3.0... +copying CHANGELOG.md -> nfl_data_py-0.3.0 +copying CONTRIBUTING.md -> nfl_data_py-0.3.0 +copying LICENSE -> nfl_data_py-0.3.0 +copying README.md -> nfl_data_py-0.3.0 +copying code_of_conduct.md -> nfl_data_py-0.3.0 +copying setup.py -> nfl_data_py-0.3.0 +copying tox.ini -> nfl_data_py-0.3.0 +copying data\coaching_history.csv -> nfl_data_py-0.3.0\data +copying data\combine.csv -> nfl_data_py-0.3.0\data +copying data\drafts.csv -> nfl_data_py-0.3.0\data +copying data\qbr.csv -> nfl_data_py-0.3.0\data +copying data\schedules\1999.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2000.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2001.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2002.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2003.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2004.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2005.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2006.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2007.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2008.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2009.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2010.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2011.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2012.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2013.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2014.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2015.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2016.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2017.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2018.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2019.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2020.csv -> nfl_data_py-0.3.0\data\schedules +copying data\schedules\2021.csv -> nfl_data_py-0.3.0\data\schedules +copying nfl_data_py\__init__.py -> nfl_data_py-0.3.0\nfl_data_py +copying nfl_data_py.egg-info\PKG-INFO -> nfl_data_py-0.3.0\nfl_data_py.egg-info +copying nfl_data_py.egg-info\SOURCES.txt -> nfl_data_py-0.3.0\nfl_data_py.egg-info +copying nfl_data_py.egg-info\dependency_links.txt -> nfl_data_py-0.3.0\nfl_data_py.egg-info +copying nfl_data_py.egg-info\requires.txt -> nfl_data_py-0.3.0\nfl_data_py.egg-info +copying nfl_data_py.egg-info\top_level.txt -> nfl_data_py-0.3.0\nfl_data_py.egg-info +copying nfl_data_py\tests\nfl_test.py -> nfl_data_py-0.3.0\nfl_data_py\tests +copying nfl_data_py\tests\__pycache__\nfl_test.cpython-35-pytest-6.1.2.pyc -> nfl_data_py-0.3.0\nfl_data_py\tests\__pycache__ +copying nfl_data_py\tests\__pycache__\nfl_test.cpython-37-pytest-6.2.4.pyc -> nfl_data_py-0.3.0\nfl_data_py\tests\__pycache__ +copying nfl_data_py\tests\__pycache__\nfl_test.cpython-37-pytest-7.1.0.pyc -> nfl_data_py-0.3.0\nfl_data_py\tests\__pycache__ +copying nfl_data_py\tests\__pycache__\nfl_test.cpython-37-pytest-7.1.2.pyc -> nfl_data_py-0.3.0\nfl_data_py\tests\__pycache__ +copying nfl_data_py\tests\__pycache__\nfl_test.cpython-39-pytest-6.2.4.pyc -> nfl_data_py-0.3.0\nfl_data_py\tests\__pycache__ +copying nfl_data_py\tests\__pycache__\nfl_test.cpython-39-pytest-6.2.5.pyc -> nfl_data_py-0.3.0\nfl_data_py\tests\__pycache__ +copying nfl_data_py\tests\__pycache__\nfl_test.cpython-39-pytest-7.1.2.pyc -> nfl_data_py-0.3.0\nfl_data_py\tests\__pycache__ +Writing nfl_data_py-0.3.0\setup.cfg +creating '.tox\dist\nfl_data_py-0.3.0.zip' and adding 'nfl_data_py-0.3.0' to it +adding 'nfl_data_py-0.3.0' +adding 'nfl_data_py-0.3.0\data' +adding 'nfl_data_py-0.3.0\nfl_data_py' +adding 'nfl_data_py-0.3.0\nfl_data_py.egg-info' +adding 'nfl_data_py-0.3.0\CHANGELOG.md' +adding 'nfl_data_py-0.3.0\code_of_conduct.md' +adding 'nfl_data_py-0.3.0\CONTRIBUTING.md' +adding 'nfl_data_py-0.3.0\LICENSE' +adding 'nfl_data_py-0.3.0\PKG-INFO' +adding 'nfl_data_py-0.3.0\README.md' +adding 'nfl_data_py-0.3.0\setup.cfg' +adding 'nfl_data_py-0.3.0\setup.py' +adding 'nfl_data_py-0.3.0\tox.ini' +adding 'nfl_data_py-0.3.0\data\schedules' +adding 'nfl_data_py-0.3.0\data\coaching_history.csv' +adding 'nfl_data_py-0.3.0\data\combine.csv' +adding 'nfl_data_py-0.3.0\data\drafts.csv' +adding 'nfl_data_py-0.3.0\data\qbr.csv' +adding 'nfl_data_py-0.3.0\data\schedules\1999.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2000.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2001.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2002.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2003.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2004.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2005.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2006.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2007.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2008.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2009.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2010.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2011.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2012.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2013.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2014.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2015.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2016.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2017.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2018.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2019.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2020.csv' +adding 'nfl_data_py-0.3.0\data\schedules\2021.csv' +adding 'nfl_data_py-0.3.0\nfl_data_py\tests' +adding 'nfl_data_py-0.3.0\nfl_data_py\__init__.py' +adding 'nfl_data_py-0.3.0\nfl_data_py\tests\__pycache__' +adding 'nfl_data_py-0.3.0\nfl_data_py\tests\nfl_test.py' +adding 'nfl_data_py-0.3.0\nfl_data_py\tests\__pycache__\nfl_test.cpython-35-pytest-6.1.2.pyc' +adding 'nfl_data_py-0.3.0\nfl_data_py\tests\__pycache__\nfl_test.cpython-37-pytest-6.2.4.pyc' +adding 'nfl_data_py-0.3.0\nfl_data_py\tests\__pycache__\nfl_test.cpython-37-pytest-7.1.0.pyc' +adding 'nfl_data_py-0.3.0\nfl_data_py\tests\__pycache__\nfl_test.cpython-37-pytest-7.1.2.pyc' +adding 'nfl_data_py-0.3.0\nfl_data_py\tests\__pycache__\nfl_test.cpython-39-pytest-6.2.4.pyc' +adding 'nfl_data_py-0.3.0\nfl_data_py\tests\__pycache__\nfl_test.cpython-39-pytest-6.2.5.pyc' +adding 'nfl_data_py-0.3.0\nfl_data_py\tests\__pycache__\nfl_test.cpython-39-pytest-7.1.2.pyc' +adding 'nfl_data_py-0.3.0\nfl_data_py.egg-info\dependency_links.txt' +adding 'nfl_data_py-0.3.0\nfl_data_py.egg-info\PKG-INFO' +adding 'nfl_data_py-0.3.0\nfl_data_py.egg-info\requires.txt' +adding 'nfl_data_py-0.3.0\nfl_data_py.egg-info\SOURCES.txt' +adding 'nfl_data_py-0.3.0\nfl_data_py.egg-info\top_level.txt' +removing 'nfl_data_py-0.3.0' (and everything under it) diff --git a/CHANGELOG.md b/CHANGELOG.md index a04f755..ee9fc23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,7 +42,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.2.9] - 2022-08-18 - Fixed compatibility issue between python and pandas -## [0.2.10] - 2022-08-20 +## [0.2.11] - 2022-08-20 - Actually fixed issue between python and pandas not resolved in 0.2.9 - Dropped python 3.5 support from nfl_data_py to allow for parquet file usage +## [0.3.0] - 2022-08-20 +- Added import functionality for participation, contract, and player data made previously available through nflReadR + diff --git a/nfl_data_py/__init__.py b/nfl_data_py/__init__.py index d25488f..f61e38a 100644 --- a/nfl_data_py/__init__.py +++ b/nfl_data_py/__init__.py @@ -27,9 +27,11 @@ import_officials() - import details on game officials import_schedules() - import weekly teams schedules import_rosters() - import team rosters +import_players() - import descriptive data for all players import_depth_charts() - import team depth charts import_injuries() - import team injury reports import_ids() - import mapping of player ids for more major sites +import_contracts() - import contract data import_win_totals() - import win total lines for teams import_sc_lines() - import weekly betting lines for teams import_draft_picks() - import draft pick history @@ -43,12 +45,13 @@ """ -def import_pbp_data(years, columns=None, downcast=True, cache=False, alt_path=None): +def import_pbp_data(years, columns=None, include_participation=True, downcast=True, cache=False, alt_path=None): """Imports play-by-play data Args: years (List[int]): years to get PBP data for columns (List[str]): only return these columns + include_participation (bool): whether to include participation stats or not downcast (bool): convert float64 to float32, default True cache (bool): whether to use local cache as source of pbp data alt_path (str): path for cache if not nfl_data_py default @@ -66,6 +69,9 @@ def import_pbp_data(years, columns=None, downcast=True, cache=False, alt_path=No if columns is None: columns = [] columns = [x for x in columns if x not in ['season']] + + if all([include_participation, len(columns) != 0]): + columns = columns + [x for x in ['play_id','old_game_id'] if x not in columns] # potential sources for pbp data url1 = r'https://github.com/nflverse/nflverse-data/releases/download/pbp/play_by_play_' @@ -83,7 +89,7 @@ def import_pbp_data(years, columns=None, downcast=True, cache=False, alt_path=No else: dpath = alt_path - # read in pbp data + # read in pbp data for year in years: if cache is True: seasonStr = f'season={year}' @@ -109,9 +115,13 @@ def import_pbp_data(years, columns=None, downcast=True, cache=False, alt_path=No raw = pandas.DataFrame(data) raw['season'] = year - + + if all([include_participation, year >= 2016, not cache]): + path = r'https://github.com/nflverse/nflverse-data/releases/download/pbp_participation/pbp_participation_{}.parquet'.format(year) + partic = pandas.read_parquet(path) + raw = raw.merge(partic, how='left', on=['play_id','old_game_id']) + pbp_data.append(raw) - print(str(year) + ' done.') except: @@ -131,7 +141,7 @@ def import_pbp_data(years, columns=None, downcast=True, cache=False, alt_path=No def cache_pbp(years, downcast=True, alt_path=None): """Cache pbp data in local location to allow for faster loading - + Args: years (List[int]): years to cache PBP data for downcast (bool): convert float64 to float32, default True @@ -139,33 +149,33 @@ def cache_pbp(years, downcast=True, alt_path=None): Returns: DataFrame """ - + if not isinstance(years, (list, range)): raise ValueError('Input must be list or range.') - + if min(years) < 1999: raise ValueError('Data not available before 1999.') - + if alt_path is None: alt_path = '' - + plays = pandas.DataFrame() url1 = r'https://github.com/nflverse/nflverse-data/releases/download/pbp/play_by_play_' url2 = r'.parquet' appname = 'nfl_data_py' appauthor = 'cooper_dff' - + # define path for caching if len(alt_path) > 0: path = alt_path else: path = os.path.join(appdirs.user_cache_dir(appname, appauthor), 'pbp') - + # check if drectory exists already if not os.path.isdir(path): os.makedirs(path) - + # delete seasons to be replaced for folder in [os.path.join(path, x) for x in os.listdir(path) for y in years if ('season='+str(y)) in x]: for file in os.listdir(folder): @@ -182,6 +192,11 @@ def cache_pbp(years, downcast=True, alt_path=None): raw = pandas.DataFrame(data) raw['season'] = year + if year >= 2016: + path2 = r'https://github.com/nflverse/nflverse-data/releases/download/pbp_participation/pbp_participation_{}.parquet'.format(year) + part = pandas.read_parquet(path2) + raw = raw.merge(part, how='left', on=['play_id','old_game_id']) + if downcast: cols = raw.select_dtypes(include=[numpy.float64]).columns raw.loc[:, cols] = raw.loc[:, cols].astype(numpy.float32) @@ -381,6 +396,16 @@ def calc_age(x): return rosters +def import_players(): + """Import descriptive data for all players + + Returns: + DataFrame + """ + df = pandas.read_parquet(r'https://github.com/nflverse/nflverse-data/releases/download/players/players.parquet') + return df + + def import_team_desc(): """Import team descriptive data @@ -636,6 +661,18 @@ def import_ids(columns=None, ids=None): return df + +def import_contracts(): + """Imports historical contract data + + Returns: + DataFrame + """ + + df = pandas.read_parquet(r'https://github.com/nflverse/nflverse-data/releases/download/contracts/historical_contracts.parquet') + + return df + def import_ngs_data(stat_type, years=None): """Imports seasonal NGS data @@ -816,8 +853,8 @@ def import_snap_counts(years): raise ValueError('Input must be list or range.') if len(years) > 0: - if min(years) < 2013: - raise ValueError('Data not available before 2013.') + if min(years) < 2012: + raise ValueError('Data not available before 2012.') df = pandas.DataFrame() diff --git a/nfl_data_py/tests/nfl_test.py b/nfl_data_py/tests/nfl_test.py index 6eb8bbb..43aef1e 100644 --- a/nfl_data_py/tests/nfl_test.py +++ b/nfl_data_py/tests/nfl_test.py @@ -134,3 +134,16 @@ def test_cache(self): nfl.cache_pbp([2020]) s = nfl.import_pbp_data([2020], cache=True) self.assertEqual(True, isinstance(s, pd.DataFrame)) + +class test_contracts(TestCase): + def test_contracts(self): + s = nfl.import_contracts() + self.assertEqual(True, isinstance(s, pd.DataFrame)) + self.assertTrue(len(s) > 0) + +class test_players(TestCase): + def test_players(self): + s = nfl.import_players() + self.assertEqual(True, isinstance(s, pd.DataFrame)) + self.assertTrue(len(s) > 0) + diff --git a/setup.py b/setup.py index 597aef2..3a1a765 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ EMAIL = 'cooper.dff11@gmail.com' AUTHOR = 'cooperdff' REQUIRES_PYTHON = '>=3.6.0' -VERSION = '0.2.11' +VERSION = '0.3.0' # What packages are required for this module to be executed?