Built on the nfl-data-py module, the nfl_custom_aggs project allows you to import aggregated statistics by player, team, division, conference, or league at the level of detail you want: season, week, half, quarter, or drive. You can also just import the raw play-by-play data with the enrichments used to create the aggregations (fantasy data, individual play lineups, etc.).
Clone this repository to your local desktop.
$ git clone https://github.com/m-a-fayyaz/nfl_custom_aggs.git
In a python file or Jypyter notebook in the root folder, import the functions in the utils folder.
from utils import *
import_enrich_pbp_data(years, regular=True)
Returns PBP data from the nfl-data-py module with additional columns (fantasy data, individual play lineups, etc.).
years (list[int], range) : required, list of seasons to pull data for (as early as 1999)
regular (boolean) : required, specify if you only want regular season data. Defaults to True.
import_off_agg_data(years, regular=True, level='season', by='player', pbp_enrich_df=None)
Returns aggregated statistics for individual offensive players at the level of detail you want (season, week, half, quarter, or drive).
years (list[int], range) : required, list of seasons to pull data for (as early as 1999)
regular (boolean) : required, specify if you only want regular season data. Defaults to True.
level (string) : required, level of aggregation (season, week, half, quarter, or drive). Defaults to season.
by (string) : required, specify subject to aggregate by (player, team, division, conference, league) Defaults to player.
pbp_enrich_df (pd.DataFrame) : optional, pass through pre-loaded enriched pbp dataframe. Pulls from nfl-data-py module if empty.