← Back

NFL-data-py in a Spreadsheet - Next Gen NFL Stats in Row Zero

2024-12-04 // Mark Tressler

Open free NFL-data-py stats spreadsheet

nfl-data-py data imported into a spreadsheet

The nfl_data_py python package is a great way to access next gen NFL stats and advanced football analytics on every player, play, and game. We've used Row Zero, a next-gen spreadsheet built for big data, to pull these NFL stats in a spreadsheet that's easy for any football fan with basic spreadsheet skills to use.

From here you can analyze every NFL player and play. Look up Lamar Jackson next gen stats from his MVP season, analyze every TJ Watt sack, or create your own NFL stats and awards.

Using a few ready-to-use python functions, this post will show you how to use python to pull NFL stats into a powerful Row Zero spreadsheet. Even if you don't know python, you can use Row Zero and NFL-data-py to analyze next gen NFL stats using our free NFL stats spreadsheet template.

Open free NFL-data-py stats spreadsheet

This nfl-data-py tutorial contains the following sections:

What is nfl_data_py?

nfl_data_py is an open source Python package for NFL data. You can learn more about the project on the nfl_data_py Github page. The nfl_data_py Python package pulls data from nflfastR, nfldata, and Draft Scout. NFL-data-py is effectively a free API for NFL stats that can be accessed via Python.

What is Row Zero

Row Zero is a next-gen spreadsheet built for big data. Row Zero works like Excel and Google Sheets but can handle 1000x bigger data sets, connect directly to your data sources, and has a native Python development environment to easily create custom spreadsheet functions or import data using Python packages like NFL_data_py.

Explore the NFL-data-py Spreadsheet Template

We've built an easy to use NFL-data-py spreadsheet template to help any user get started. Simply open the spreadsheet and start playing around. You can view next gen NFL stats for any player for any season or drill down into game-by-game and play-by-play NFL stats for any player or team. Be sure to read about updating data and using data tables. While everything is pre-built in the template, you can view instructions on how to import NFL-data-py and build this template.

NFL Player Stats by Season

View NFL stats by player for any season. Data is updated through the most recent week's NFL games. Here's a look at QB stat leaders so far in 2024. nfl next gen passing statistics This NFL stats package includes all of the standard stats by position as well advanced NFL statistics and fantasy football stats and scoring. You can also look at past years to relive your favorite NFL seasons.

NFL Next Gen Stats by Game and Season

View NFL next gen stats for every player and game. These advanced football metrics offer a deeper analysis of NFL player performance beyond standard NFL stats. The NFL-data-py python package includes next gen passing stats, rushing stats, and receiving stats for any season and is current through the most recent week of games.

NFL Next Gen Passing Stats

Explore NFL next gen passing stats to analyze QB stat leaders for different categories. For example, the QBs with the best completion percentage above expectation are Jalen Hurts, Sam Darnold, and Jared Goff so far in 2024. nfl next gen passing statistics The NFL-data-py python package has many next gen QB stats and advanced passing statistics including average time to throw, avg completed air yards, avg intended air yards, aggressiveness, max completed air distance, and completion percentage above expectation, in addition to standard NFL QB stats like pass yards, TDs, interceptions and passer rating.

NFL Next Gen Rushing Stats

Exploring NFL next gen rushing stats shows how dominant Derrick Henry and Saquon Barkley have been in the 2024 NFL season. Here, we see that each is averaging 2 yards per carry over expected for each attempt this season. nfl next gen rushing statistics

The NFL-data-py python package includes dozens of next gen RB stats and advanced NFL rushing statistics like efficiency, attempts vs 8 defenders in the box, rush yards over expected per attempt, etc. in addition to standard NFL RB stats.

NFL Next Gen Receiving Stats

Digging into NFL next gen receiving stats reveals various stat leaders for different categories. For example, the WR with the biggest average separation (the best WR at getting open) in 2024 are Khalil Shakir, Jayden Reed, and Zay Flowers. nfl next gen rushing statistics The NFL-data-py python package includes various next generation WR stats and advanced receiving stats including average cushion, average separation, catch percentage, avg YAC, and avg YAC above expectation.

Game-by-game NFL stats by season

View game-by-game stats for every player. Build your own NFL stat tracker in a spreadsheet, drill into next-gen NFL stats, or build your own fantasy football analytics. Here's an example of Saquon Barkley stats by game for 2024. nfl next gen rushing statistics

And the Top 10 Fantasy Football performances so far in 2024, with Ja'Marr Chase's 55.4 fantasy points (PPR) in week 10 versus Baltimore as the top performance. nfl next gen rushing statistics

Play-by-play NFL stats by season

The NFL play-by-play stats in NFL-data-py are very comprehensive. When pulled into a Row Zero spreadsheet, the data goes to column NZ, which is 390 columns of unique data fields and has 50,000 rows for nearly 20 million cells of NFL play-by-play data. This dataset does not include the current season but does include every play from every game in prior seasons, including NFL playoff game stats. It also includes defensive statistics, so you can analyze every TJ Watt sack or Fred Warner tackle. next gen tj watt sack stats

There is a separate tab for play-by-play FTN stats which is up-to-date through the most recent NFL week games but is limited to situational QB and passing statistics.

Weekly NFL Rosters and Player Bios

View weekly NFL roster data. While weekly NFL roster data may seem less exciting, this data set includes some really great player characteristics like college, draft round, age, height, weight, etc. It's a great way to XLOOKUP player characteristics to combine with other stats. Here are a few examples:

Colleges with the most active NFL players

nfl next gen rushing statistics Alabama has the most active NFL players this season with 80 total players rostered. Ohio State and LSU round out the top 3.

Age, height and weight by position across all NFL players

nfl next gen rushing statistics Here are a few of the extremes for NFL players this season:

  • Oldest NFL player: Jon Ryan, a punter for Seattle, is the oldest NFL player at the age of 43 and was born on 11/26/1981. Jason Peters, an OL for Seattle, is only a few months behind him and Aaron Rodgers rounds out the 3rd oldest player and oldest NFL QB at 41 years old.
  • Tallest NFL player: Dan Skipper (OL Detroit), Caleb Jones (OL New England), and Lorenz Metz (OL Tampa Bay) are the tallest NFL players at 81 inches tall or 6 ft, 9 inches.
  • Heaviest NFL player: Trent Brown (OL Cincinnati) and Daniel Faalele (OL Baltimore) are the heaviest NFL players, with both listed at 380 lbs.
  • Shortest NFL player: Several NFL players are listed at 66 inches or 5 ft, 6 inches tall including J.J Taylor (RB Houston) and Deuce Vaughn (RB Dallas)

Count of NFL players by draft number and position

position with most undrafted nfl players 43% of NFL players were undrafted including 27% of QBs. Top 10 draft picks are fairly well distributed across positions.

How to Get NFL Data Py Data into a Spreadsheet

Important Note About Data Tables and Updating Data

All of the NFL-data-py python functions in this tutorial will return a data table in your spreadsheet. There are two key advantages to using data tables: 1) data tables make it easier to work with large datasets and 2) data tables dynamically update as new data comes in. So when the new week's data is available, it will dynamically update the data table and everything built on top of it (e.g. pivot tables, charts, formulas, etc.). At any time, you can switch to normal spreadsheet mode by using the Explode feature by right clicking on the data table and then clicking 'explode' to paste values from the data table into the underlying cells. Note however, that this breaks the connection to the nfl data py API data so your data will not update as new data comes in. That's why we recommend keeping your data in data tables. Right-click on a data table to pull up the menu for creating pivot tables, charts, copying, exporting, etc.

Getting started with nfl-data-py and Row Zero

Getting started is easy. You can skip ahead to the pre-built NFL spreadsheet template here. Or continue reading for the nfl-data-py tutorial. These instructions will help you use NFL-data-py as a free NFL API to look up next gen NFL statistics in a powerful online spreadsheet.

Step 1: Open a new workbook

Go to Row Zero and login or signup for free to get started. Create a new workbook and click on the </> Code button in the top right to open the Python code window. open python code window to import nfl-data-py python package

Step 2: Import Python packages

Next import the Python packages needed for this analysis, which are the nfl_data_py package, pandas (data table functionality), and plotly.graph_objects. You can import Python packages by typing the following commands into the code window and hitting Run. View documentation for the Row Zero code window here.

import pandas as pd
import plotly.graph_objects as go
import nfl_data_py as nfl

Step 3: Get NFL player seasonal data

To get NFL player stats by season, we use the function below. The seasonal data will return a data table in which there is a row for each player, listed alphabetically and every column is a common NFL football stat you can use in your analysis. This data is updated through the most recent week's NFL games.

def get_seasonal_data(year):
    year_list = []
    year_list.append(int(year))
    df = nfl.import_seasonal_data(year_list)
    id_df = nfl.import_ids()
    id_df = id_df[['gsis_id','name']]
    df = pd.merge(df,  
                     id_df,  
                     left_on = 'player_id',
                     right_on = 'gsis_id',
                     how ='left')
    cols = df.columns.tolist()
    cols = cols[-1:] + cols[:-2]
    df = df[cols]
    df = df.sort_values('name')

    return df

Paste this code into the code window and click Run. You should get a message Build completed. Once the function is created, type the function into a cell in the spreadsheet and either reference a cell with the year or include the year in the function. For example =get_seasonal_data(B0) where B0 contains the year 2024 or type =get_seasonal_data("2024") into a cell and all the data will import into a data table. Once the data populates, use the column headers to filter and sort to the data you need. You can also write Excel-compatible formulas or right-click in the data table to create a pivot table, chart, or copy. nfl player statistics by season

Step 4: NFL game-by-game stats for NFL players by season

To look at weekly NFL game stats by player, use the function below. This function is executed just like the previous. Drop the function =get_weekly_data_(B0) into a cell and list the year in cell B0.

def get_weekly_data(year):
    year_list = []
    year_list.append(int(year))
    df = nfl.import_weekly_data(year_list)

    return df

Once the function is executed, you can filter to any player and game. nfl player statistics by game

Step 5: NFL play-by-play data for any NFL season

To get play-by-play NFL stats, use the function below to run the Python script to pull NFL statistics for every play in a particular NFL season. These NFL play-by-play stats are very comprehensive. For example, the data for the 2023 NFL season has 50,000 rows with 390 columns of unique data fields. That's nearly 20 million cells of NFL data! You can create your own NFL football stats and build custom NFL analytics. Unlike the other datasets in this template, this dataset does not include the current season but does include every play from every game in prior seasons, including NFL playoff game stats and does include defensive statistics.

def get_play_by_play_data(year):
    year_list = []
    year_list.append(int(year))
    df = nfl.import_pbp_data(year_list)

Like we referenced above, type the function into a cell in the spreadsheet and either reference a cell with the year or include the year in the function. For example =get_play_by_play_data(B0) where B0 contains the year 2023 or type =get_seasonal_data("2023") into a cell and all data will import as a data table. play-by-play nfl statistics

Step 6: Weekly NFL team roster data

To access NFL team roster data by game, use the function below and reference a cell containing the year to pull in data, like the image below.

def get_weekly_roster_data(year):
    year_list = []
    year_list.append(int(year))
    df = nfl.import_weekly_rosters(year_list)

    return df

nfl-data-py nfl roster data by game

NFL roster data includes: season, week, team, position, depth chart position, jersey_number, roster status, player name, birth date, height, weight, college, player id, years experience, rookie year, draft team, draft number, and age.

Step 7: Next generation NFL stats by player

The NFL-data-py python package includes NFL next gen stats for each player and game. These advanced football statistics offer a deeper understanding of NFL player performance beyond standard NFL football stats. The next generation stats function requires two inputs, the stat_type (e.g. passing, rushing, or receiving) and the year.

def get_ngs_data(stat_type, year):
    year_list = []
    year_list.append(int(year))
    df = nfl.import_ngs_data(stat_type, year_list)

    return df

python nfl-data-py next gen stats in a spreadsheet

Step 8: FTN Stats

FTN provides in-depth NFL analytics and player projections. You can access some of the FTN data using the function below. The FTN data accessible in NFL-data-py includes individual play data, like QB location, no huddle, is play action, is trick play, is qb out of pocket, is throw away, is catchable, is contested, is QB sneak, is blitz, is pass rush, and a number of others.

def get_ftn_data(year):
    year_list = []
    year_list.append(int(year))
    df = nfl.import_ftn_data(year_list)

    return df

nfl data py ftn stats

Conclusion

NFL-data-py can be used as a free NFL API for stats and player data. With a free Row Zero account and a few python scripts, you can easily import NFL football stats from NFL-data-py into a spreadsheet. If you don't know any python, you can use our NFL stats spreadsheet template to get started and dig into NFL next gen statistics and build your own NFL football analytics. Please note that this spreadsheet template is provided for free and is intended for fun and personal use only and to help users get started with the nfl-data-py package. If you want to pull NFL-data-py data into a spreadsheet, Row Zero is your best choice for three reasons: 1) big data power that can handle 1000x bigger data sets vs Excel's row limit, 2) native python spreadsheet code window that makes it super easy to import NFL-data-py data, 3) dynamic data tables that automatically update your spreadsheet as new game data is available. You can try Row Zero for free at rowzero.io.

Open Free NFL-data-py Stats Spreadsheet

NFL-data-py example code for spreadsheet template

Here's the full python code used to import nfl-data-py in the NFL spreadsheet template.

import pandas as pd
import plotly.graph_objects as go
import nfl_data_py as nfl

def get_seasonal_data(year):
    year_list = []
    year_list.append(int(year))
    df = nfl.import_seasonal_data(year_list)
    id_df = nfl.import_ids()
    id_df = id_df[['gsis_id','name']]
    df = pd.merge(df,  
                     id_df,  
                     left_on = 'player_id',
                     right_on = 'gsis_id',
                     how ='left')
    cols = df.columns.tolist()
    cols = cols[-1:] + cols[:-2]
    df = df[cols]
    df = df.sort_values('name')

    return df

def get_weekly_data(year):
    year_list = []
    year_list.append(int(year))
    df = nfl.import_weekly_data(year_list)

    return df

def get_play_by_play_data(year):
    year_list = []
    year_list.append(int(year))
    df = nfl.import_pbp_data(year_list)

    return df

def get_weekly_roster_data(year):
    year_list = []
    year_list.append(int(year))
    df = nfl.import_weekly_rosters(year_list)

    return df

def get_ngs_data(stat_type, year):
    year_list = []
    year_list.append(int(year))
    df = nfl.import_ngs_data(stat_type, year_list)

    return df

def get_ftn_data(year):
    year_list = []
    year_list.append(int(year))
    df = nfl.import_ftn_data(year_list)

    return df