Skip to content

Instantly share code, notes, and snippets.

@mrphilroth
mrphilroth / positions.py
Last active September 24, 2023 20:48
Yahoo Fantasy Basketball Positions
#!/usr/bin/env python
import pandas as pd
import requests
headers = {
"authority": "pub-api-ro.fantasysports.yahoo.com",
"accept": "*/*",
"accept-language": "en-US,en;q=0.9,ca;q=0.8,da;q=0.7",
"cache-control": "no-cache",
[{"gamecode": "0021800001", "gamedate": "2018-10-16", "teamcode": 1610612755, "teamname": "Philadelphia 76ers", "teamgamenum": 1, "scored": 87, "allowed": 105, "scorediff": -18, "win": false, "location": "away"}, {"gamecode": "0021800014", "gamedate": "2018-10-18", "teamcode": 1610612755, "teamname": "Philadelphia 76ers", "teamgamenum": 2, "scored": 127, "allowed": 108, "scorediff": 19, "win": true, "location": "home"}, {"gamecode": "0021800029", "gamedate": "2018-10-20", "teamcode": 1610612755, "teamname": "Philadelphia 76ers", "teamgamenum": 3, "scored": 116, "allowed": 115, "scorediff": 1, "win": true, "location": "home"}, {"gamecode": "0021800049", "gamedate": "2018-10-23", "teamcode": 1610612755, "teamname": "Philadelphia 76ers", "teamgamenum": 4, "scored": 132, "allowed": 133, "scorediff": -1, "win": false, "location": "away"}, {"gamecode": "0021800059", "gamedate": "2018-10-24", "teamcode": 1610612755, "teamname": "Philadelphia 76ers", "teamgamenum": 5, "scored": 108, "allowed": 123, "scorediff": -15,
@mrphilroth
mrphilroth / fantasy_positions.py
Last active October 11, 2022 00:18
Yahoo NBA Fantasy Positions
#!/usr/bin/python
import requests
import numpy as np
import pandas as pd
from lxml import html
base_url = "http://sports.yahoo.com/nba/teams"
teams = [
"atlanta",
@mrphilroth
mrphilroth / scrape.py
Created August 12, 2016 01:31
Scrape basketball data and process the play by play data
#!/usr/bin/python
import os
import sys
import time
import redis
import requests
import argparse
import datetime
import numpy as np
@mrphilroth
mrphilroth / testmeta.go
Created December 21, 2015 20:59
Simple Go file to help diagnose go-plus issue
package main
import "log"
func main() {
something := 2
somethingElse := 3
veryImportantSomething := something * somethingElse
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mrphilroth
mrphilroth / scipy2015.md
Last active June 6, 2018 07:55
SciPy 2015 Talk Bibliography
@mrphilroth
mrphilroth / README.md
Last active December 21, 2015 09:59
MLB Past and Future Payrolls

This is a rich visualization of the past and future payroll obligations of current MLB franchises. Click the arrows or use the left and right arrow keys to change the year. Click on a team in the top bar chart to see that team's contract history. Click on a player in the bottom chart to see details about that player. All data from Baseball Reference who themselves use Cot's Baseball Contracts. Full accompanying blog post is here.

@mrphilroth
mrphilroth / README.md
Last active December 21, 2015 02:49
Baseball Payroll Prototype

Here I show the total payroll of each baseball team from 1999 to the present. Use the arrow keys to change the year. Future years show player contracts that the team is obligated to pay.

TODO: Color the teams bars with team colors Sort the total payroll from low to high. Then get the bars to move around when changing years. Ghost bars in future years equal to average recent payroll.