Skip to content

Instantly share code, notes, and snippets.

@guga31bb
guga31bb / nflscrapr.md
Last active August 18, 2023 07:45
Simple guide for using nflscrapR

THIS IS OUTDATED. PLEASE FOLLOW THE FOLLOWING LINK

--> A beginner's guide to nflfastR <--

Basic nflscrapR tutorial

I get a lot of questions about how to get nflscrapR up and running. This guide is intended to help new users build interesting tables or charts from the ground up, taking the raw nflscrapR data.

Quick word if you're new to programming: all of this is happening in R. Obviously, you need to install R on your computer to do any of this. Make sure you save what you're doing in a script (in R, File --> New script) so you can save your work and run multiple lines of code at once. To run code from a script, highlight what you want, right click, and select Run line. As you go through your R journey, you might get stuck and have to google a bunch of things, but that's totally okay and normal. That's how I wrote this thing!

@Deryck97
Deryck97 / play_by_play_python.md
Last active December 10, 2022 08:54
An introduction to working with nflscrapR data in Python

nflscrapR Python Guide

This is an introduction to working with nflscrapR data in Python. This is inspired by this guide by Ben Baldwin.

Using Jupyter Notebooks which come pre-installed with Anaconda is typically the best way to work with data in Python. This guide assumes you are using the Ananconda distribution and therefore already have the required packages installed. If you are not using the Anaconda distribution, install numpy, pandas, and matplotlib.

Once Anaconda has been downloaded and installed, open the Anaconda Navigator. Click launch on the Jupyter Notebook section which will open in your browser.

Collecting and Cleaning Data

There are a couple ways to get nflscrapR data. While you don't necessarily need R for historical data, it is necessary for getting data that has not been uploaded to github. My preferred process is to get data u

@aparrish
aparrish / enough-python.ipynb
Last active September 16, 2023 16:16
Just enough Python!
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aparrish
aparrish / spacy-extraction-medley.ipynb
Created August 1, 2019 20:10
Example code for extracting things with spacy and writing them out to text files and then reading them in again.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

An Alternate Approach to Measuring the Effect of Accumulated QB Hits on Passing Performance

This analysis is a follow-up to @benbbaldwin's post The accumulation of QB hits vs passing efficiency where his conclusion was that:

[For] a given level of hits, there is no evidence that the accumulation of hits makes any difference throughout the course of a game.

As the title suggests, this analysis will take a different approach to measuring the hypothesized effect.

1. Data

Here is the code to get the passing data we'll be using from nflscrapR-data:

Team Strength Exclusion Bias in Expected Points Models

@nflscrapR's Expected Points (EP) is a popular metric among analysts doing public research of play in the NFL. Detailed in the creators' research paper, the metric is derived from a model that was built as a part of a larger system designed to calculate individual wins above replacement values for offensive skill players.

The authors very graciously made public all of their data (nflscrapR-data) and code (nflWAR, nflscrapR-models, nflscrapR) for this project, including the code used to build the EP model. In the init_ep_fg_models.R file of the nflscrapR-models repository, we can see that the following variables are used

@Robotto
Robotto / gist:9db27ceead01c3ce7ece6406881f8c92
Last active October 31, 2021 18:55 — forked from criccomini/gist:3805436
Schedules & Scores API for Streaming Live Sports Stats - MSNBC
import pytz
import datetime
import time
import urllib2
import json
import os
import elementtree.ElementTree as ET
url = 'http://scores.nbcsports.com/ticker/data/gamesNEW.js.asp?jsonp=true&sport=%s&period=%d&random=%d'
@Mrpatekful
Mrpatekful / dialogue_generation.ipynb
Created November 17, 2019 12:30
dialogue_generation.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@paultopia
paultopia / zotero_add.py
Created April 4, 2020 21:18
hacking together zotero magic add
import requests
import json
import os
from copy import deepcopy
APIKEY = os.environ["ZOTEROKEY"]
ACCOUNT = os.environ["ZOTEROACCOUNT"]
TESTITEM = '10.2307/4486062' # just the same example item used on https://github.com/zotero/translation-server
def get_item_from_identifier(identifier):
endpoint = "http://zotglitch.glitch.me/search"