Skip to content

Instantly share code, notes, and snippets.

@BlueSCar
Created March 29, 2020 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BlueSCar/90ffedb60534b25080621bf908d92232 to your computer and use it in GitHub Desktop.
Save BlueSCar/90ffedb60534b25080621bf908d92232 to your computer and use it in GitHub Desktop.
import numpy as np
import pandas as pd
import requests
pd.set_option('display.float_format', lambda x: '%.8f' % x)
season = 2
day = 3
response = requests.get('https://collegefootballrisk.com/api/territories', params={'season': season, 'day': day})
territories = pd.read_json(response.text)
territories.head()
teams = set(list(territories['owner']))
odds = pd.DataFrame()
for team in teams:
print(team)
response = requests.get('https://collegefootballrisk.com/api/team/odds', params={'team': team, 'season': season, 'day': day})
df = pd.read_json(response.text).query("territory != 'all'")
df['team'] = team
odds = pd.concat([odds, df])
odds['defeat_prob'] = 1 - odds['chance']
odds = odds[['team','defeat_prob']]
odds.groupby(['team']).prod().sort_values('defeat_prob', ascending=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment