Skip to main content

nfelo DCM

nfelo DCM is an abstraction layer for loading and caching NFL related CSVs stored on the web. DCM stands for Dataframe-CSV Mapping. The goal of the DCM is to get pandas dataframes of fresh data loaded in a way that balances simplicity, efficiency, and performance.

import nfelodcm

## Load 2 dataframes
db = nfelodcm.load(['pbp', 'games'])

## access the PBP dataframe
db['pbp']

Maps

Maps are config files that tell the DCM where data CSVs are located, how they should be retrieved, and what fields to pull. Each CSV has its own config in Maps/{table}.json, where parameters can be set for things like freshness SLAs, CSV parsing engines, iteration strategy, and assignments (mutations).

An important characteristic of these maps is that all fields must be 1) specified in the map and 2) typed. Fields not listed in the map will not be loaded. Untyped fields will throw an error.

Here is a sample config:

{
  "name": "games",
  "description": "nflgamedata games",
  "download_url": "https://raw.githubusercontent.com/nflverse/nfldata/master/data/games.csv",
  "compression": null,
  "engine": "c",
  "freshness": {
    "type": "gh_commit",
    "gh_api_endpoint": "https://api.github.com/repos/nflverse/nfldata/commits",
    "gh_release_tag": null,
    "sla_seconds": 500
  },
  "iter": {
    "type": null,
    "start": null
  },
  "assignments": [
    "fastr_team_id_repl",
    "score_clean"
  ],
  "map": {
    "game_id": "object",
    "season": "int32",
    "week": "int32",
    ...
  }
}

Config Fields

Field Description
name Table identifier
description Human-readable description
download_url URL to fetch CSV (use {0} placeholder for season in iter tables)
compression Compression type ("gzip", null)
engine Pandas CSV engine ("c", "python")
freshness.type "gh_release" or "gh_commit"
freshness.gh_api_endpoint GitHub API endpoint for freshness checks
freshness.gh_release_tag Release tag for gh_release type
freshness.sla_seconds Seconds before re-checking freshness
iter.type "season" for multi-file tables, null for single file
iter.start Starting year for season iteration
iter.accept_partial Allow success if some season files fail
assignments List of assignment function names to apply
map Column name → dtype mapping

Freshness

The DCM uses a two-tier freshness strategy:

  1. SLA Check: If the last freshness check was within sla_seconds, skip the remote check entirely
  2. Remote Check: Query GitHub API to compare remote timestamps against local state

For gh_release tables, freshness is determined by the updated_at timestamp of release assets. For gh_commit tables, freshness is based on the latest commit date.

Per-File Freshness (v0.2.1+)

For season-iterated tables (pbp, rosters, player_stats, etc.), the DCM tracks freshness per-season. When an update is needed, only stale seasons are re-downloaded - cached seasons are read from Data/Parts/{table}/. This significantly reduces bandwidth for incremental updates.

Data Storage

Mutable CSVs and JSON state are stored through the configured storage backend. The local filesystem is the default. Data is stored in this layout:

Data/
  games.csv
  pbp.csv                # Combined table CSV
  Parts/
    pbp/
      1999.csv           # Per-season cache (iter tables only)
      2000.csv
      ...
State/
  Tables/
    games.json           # Per-table state (last_local_update, last_freshness_check)
    pbp.json
  Parts/
    pbp.json             # Per-season timestamps (iter tables only)
  Global/
    season_state.json    # Current NFL season state

Assignments

Assignments are DataFrame transformations applied after data is pulled. They take a DataFrame as input and return a mutated DataFrame. Assignments are defined in Engine/Assignments/ and referenced by name in config files.

Common assignments include:

  • fastr_team_id_repl - Standardize team abbreviations
  • score_clean - Fix known data errors in game scores
  • penalty_formatting - Parse penalty descriptions

GitHub Token (Optional)

To increase GitHub API rate limits from 60/hr to 5,000/hr, create a .env file in your working directory:

GITHUB_TOKEN=ghp_your_token_here

The token is used for freshness checks only, not for downloading CSVs. A token is only relevant/needed when pulling many tables with extremely fast processing times. In most use cases, the default rate limit is sufficient.

API

import nfelodcm

# Load tables
db = nfelodcm.load(['pbp', 'games'])

# Get a single DataFrame
df = nfelodcm.get_df('pbp')

# Get table config
config = nfelodcm.get_map('games')

# List available tables
tables = nfelodcm.list_tables()

# Get current season state
season, week = nfelodcm.get_season_state('last_full_week')

# Supabase Storage. The bucket must already exist.
# prefix is optional. It places every object under that folder.
# CSVs are stored gzip compressed as .csv.gz.
# SUPABASE_STORAGE_URL is the project origin:
# https://<project-ref>.supabase.co
import os
nfelodcm.configure(storage=nfelodcm.SupabaseStorage(
    url=os.environ['SUPABASE_STORAGE_URL'],
    key=os.environ['SUPABASE_SERVICE_ROLE_KEY'],
    bucket='your-bucket',
    prefix='dcm',
))
db = nfelodcm.load(['games'])

Further Detailed Documentation

File Description
nfelodcm/Engine/Primatives/README.md Core architecture of the DCM data pipeline
tests/README.md Test suite for the DCM

Metadata

Release files for nfelodcm 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nfelodcm 0.3.0
File Size Uploaded Provenance Actions
nfelodcm-0.3.0.tar.gz 52.3 kB Without provenance Details for nfelodcm-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nfelodcm 0.3.0
File Interpreter ABI Platform Actions
nfelodcm-0.3.0-py3-none-any.whl Python 3 none any Details for nfelodcm-0.3.0-py3-none-any.whl

Total release size: 118.6 kB

Release files / nfelodcm-0.3.0.tar.gz

Download URL nfelodcm-0.3.0.tar.gz
Size 52.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9000ca471734ef115ec2b8c3df972f1e3c881c29703a22fa024b1cef034f460d
BLAKE2b-256 checksum
How to use checksums
e7d47d8056128f1fa8ae7a9b069ae450d10997de15ebe4b8349afc2d99415f52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / nfelodcm-0.3.0-py3-none-any.whl

Download URL nfelodcm-0.3.0-py3-none-any.whl
Size 66.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85ad626d10aea56eab14340ae7b7efc88bff13aff7a40cbb235946d339eecad9
BLAKE2b-256 checksum
How to use checksums
130806cd9f6f8b793b5919800ecf83604e904b1cb70cf9b3a6ee8b2a99451eca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for nfelodcm 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page