Ejemplo n.º 1
0
def GetAllRefGames(refinfo, fname):
    refstats = ['ref','exp','date','visitor','home','position','vpen','vpenyd','hpen','hpenyd']

    for ref in refinfo:
        refname = ref[1].rpartition(' ')[2]
        exp = str(ref[2])
        print 'Getting data for ' + refname

        refUrl = urllib.urlopen(ref[0]).read()
        refSoup = BeautifulSoup(refUrl, "lxml")

        i = refSoup.find_all("div", id="div_game_logs")[0]

        for row in i.findAll('tr'):
            j = []
            alltd = row.findAll("td")
            if (len(alltd) != 0):
                date = alltd[0].get_text()
                teams = alltd[1].get_text().split(' @ ')
                v = nflgame.standard_team(teams[0].rpartition(' ')[2])
                h = nflgame.standard_team(teams[1].rpartition(' ')[2])
                pos = alltd[2].get_text().replace(' ','-')
                vpen = alltd[4].get_text()
                vpenyd = alltd[5].get_text()
                hpen = alltd[7].get_text()
                hpenyd = alltd[8].get_text()

                j = np.hstack([refname, exp, date, v, h, pos, vpen, vpenyd, hpen, hpenyd])

                if (len(j) == 10):
                    refstats = np.vstack([refstats, j])
            print refstats
    np.savetxt(fname, refstats, fmt = '%s', delimiter=',')
Ejemplo n.º 2
0
    def from_nflgame(db, g):
        """
        Converts a `nflgame.game.Game` object to a `nfldb.Game`
        object.

        `db` should be a psycopg2 connection returned by
        `nfldb.connect`.
        """
        home_team = nflgame.standard_team(g.home)
        away_team = nflgame.standard_team(g.away)
        season_type = Enums._nflgame_season_phase[g.schedule['season_type']]
        day_of_week = Enums._nflgame_game_day[g.schedule['wday']]
        start_time = _nflgame_start_time(g)
        game = Game(db, g.eid, g.gamekey, start_time, g.schedule['week'],
                    day_of_week, g.schedule['year'], season_type,
                    home_team, g.score_home, g.score_home_q1,
                    g.score_home_q2, g.score_home_q3, g.score_home_q4,
                    g.score_home_q5, int(g.data['home']['to']),
                    away_team, g.score_away, g.score_away_q1,
                    g.score_away_q2, g.score_away_q3, g.score_away_q4,
                    g.score_away_q5, int(g.data['away']['to']))

        game.__drives = []
        for drive in g.drives:
            game.__drives.append(Drive.from_nflgame(game, drive))
        return game
Ejemplo n.º 3
0
    def from_nflgame(db, g):
        """
        Converts a `nflgame.game.Game` object to a `nfldb.Game`
        object.

        `db` should be a psycopg2 connection returned by
        `nfldb.connect`.
        """
        home_team = nflgame.standard_team(g.home)
        away_team = nflgame.standard_team(g.away)
        season_type = Enums._nflgame_season_phase[g.schedule['season_type']]
        day_of_week = Enums._nflgame_game_day[g.schedule['wday']]
        start_time = _nflgame_start_time(g)
        game = Game(db, g.eid, g.gamekey, start_time, g.schedule['week'],
                    day_of_week, g.schedule['year'], season_type, home_team,
                    g.score_home, g.score_home_q1, g.score_home_q2,
                    g.score_home_q3, g.score_home_q4, g.score_home_q5,
                    int(g.data['home']['to']), away_team, g.score_away,
                    g.score_away_q1, g.score_away_q2,
                    g.score_away_q3, g.score_away_q4, g.score_away_q5,
                    int(g.data['away']['to']))

        game.__drives = []
        for drive in g.drives:
            game.__drives.append(Drive.from_nflgame(game, drive))
        return game
Ejemplo n.º 4
0
def addRosterUI(ln,tn,defense):
    inp='y'
    if not defense:
        while inp.lower() not in ['n' or 'no']:
            if inp.lower()=='y' or inp.lower()=='yes':
                defen=raw_input('Please enter team name for defense: ').strip()
                while nflgame.standard_team(defen) is None:
                    defen=raw_input('Invalid team name, please try again: ').strip()
                defen=nflgame.standard_team(defen)
                defense.append(defen)
            else:
                print 'invalid input, try again.'
            inp = raw_input('Would you like to add another team for defense? (y/n): ' ).strip()

    testVar=fbTool.addRoster(ln,tn,defense)
    if not testVar:
        print 'Succesfully added roster %s!' % tn
    else:
        print 'Failed to add team...'
        if testVar == 1:
            print 'Team %s already exists in league %s' %(tn,ln)
            anotherVar = ' '
            while anotherVar not in ['y','yes','n','no']:
                anotherVar =raw_input('Try again?(y/n)').strip()
                if anotherVar.lower() in ['y','yes']:
                    tn=getTeamName(ln)
                    return addRosterUI(ln,tn,defense)
                if anotherVar.lower() in ['n','no']:
                    print 'Team not added...'
                    return -1
                if anotherVar.lower() not in ['y','yes','n','no']:
                    print 'Invalid input.  Please try again.'

        if testVar == 2:
            print 'League %s does not exist.'
            userInVar = ' '
            while userInVar not in ['y','yes','n''no']:
                userInVar = raw_input('Would you like to add it? (y/n): ').strip()
                if userInVar.lower() not in ['y','yes','n','no']:
                    print 'invalid input.  please try again.'
                if userInVar.lower() in ['y','yes']:
                    if not fbTool.addLeague(ln):
                        return addRosterUI(ln,tn,defense)
                if userInVar.lower() in ['n','no']:
                    print 'team not added.'
                    return 1
        if testVar >= 3:
            print '%s already used as defense team in league %s'%(defense[testVar-3],ln)
            oneFinalVar = ' '
            while oneFinalVar not in ['y','yes','n','no']:
                oneFinalVar = raw_input('Try again?(y/n) ').strip()
                if oneFinalVar.lower() in ['y','yes']:
                    addRosterUI(ln,tn,[])
                if oneFinalVar.lower() in ['n','no']:
                    print 'Team not added...'
                    return -1
                if oneFinalVar.lower() not in ['y','yes','n','no']:
                    print 'Invalid input, please try again.'
    return 0
Ejemplo n.º 5
0
 def add_game(self, home, away, week, season, game=None):
     """
     Add a game to the teams information
     """
     rank_info = pd.Series()
     rank_info['season'] = season
     #If we are starting a new season, reset information
     if not season == self.current_season:
         self.current_season = season
         self.wins = 0
         self.losses = 0
         self.ties = 0
         self.streak = 0
         self.win_ratio = 1.0
     rank_info['week'] = week
     if self.current_season != season:
         self.wins = 0
         self.losses = 0
         self.ties = 0
         self.streak = 0
         self.win_ratio = 1.0
         self.current_season = season
     if home in self.abbr:
         self.home = 'True'
         self.opp = away
     else:
         self.home = 'False'
         self.opp = home
     rank_info['wins'] = self.wins
     rank_info['losses'] = self.losses
     rank_info['ties'] = self.ties
     #rank_info['win_ratio'] = self.win_ratio
     rank_info['opp'] = self.opp
     rank_info['home'] = self.home
     rank_info['streak'] = self.streak
     self.data = self.data.append(rank_info, ignore_index=True)
     #Update win/loss/tie/streak information
     if not game is None:
         if '/' in game.winner:
             self.ties += 1
             self.streak = 0
         elif self.abbr in nflgame.standard_team(game.winner):
             self.wins += 1
             if self.streak >= 0:
                 self.streak += 1
             else:
                 self.streak = 1
         elif self.abbr in nflgame.standard_team(game.loser):
             self.losses += 1
             if self.streak >= 0:
                 self.streak = -1
             else:
                 self.streak -= 1
         games = self.wins + self.losses + self.ties
         if games != 0:
             self.win_ratio = round(float(self.wins) / games, 2)
         else:
             self.win_ratio = 1.0
Ejemplo n.º 6
0
def compareTeams(team1, team2, league):
    """Creates a chain linking the two given teams"""
    team1Pos = league.positionOfTeam(nflgame.standard_team(team1))
    team2Pos = league.positionOfTeam(nflgame.standard_team(team2))

    firstTeam = league.teams[team1Pos]
    secondTeam = league.teams[team2Pos]

    return league.getWinChain(firstTeam, secondTeam)
Ejemplo n.º 7
0
def team_targets(team):
    team_initials = nflgame.standard_team(team)
    if team_initials == 'SD':
        team_initials = 'LAC'
    if team_initials == 'JAC':
        team_initials = 'JAX'
    games = nflgame.games(2017, home=team_initials, away=team_initials)
    target_dict = {}
    for i, game in enumerate(games):
        target_dict[i + 1] = api.receiving_targets(game, team_initials)
    all_players = []
    for player_dict in target_dict.values():
        all_players += player_dict.keys()
    all_players = list(set(all_players))
    data = [[
        player_dict[player_name] if player_name in player_dict.keys() else ''
        for player_name in all_players
    ] for player_dict in target_dict.values()]
    background_colors = COLORS[:len(all_players)]
    labels = map(str, all_players)

    schedule = api.get_team_schedule(team_initials, 2017)
    print team_initials
    return render_template('team_targets.html',
                           team=team,
                           data=data,
                           background_colors=background_colors,
                           labels=labels,
                           schedule=convert(schedule),
                           teamInitials=team_initials)
def playerPoints(playerInfo):
    weeksPlayed = 0
    playerFound = nflgame.find(playerInfo[0], team = None)
    if playerFound != []:
        if playerFound[0].position == "K":
            points = fpKicker.kickerScore(playerFound[0], playerInfo[1], playerInfo[2])
        else:
            points = fpPlayer.fantasyPoints(playerFound[0], playerInfo[1], playerInfo[2], playerInfo[3])
        for i in playerInfo[2]:
            if str(i).isdigit():
                weeksPlayed = weeksPlayed + 1
        for w in byeWeekLists.byeWeeks:
            for t in w:
                curWeek = nflgame.live.current_year_and_week()[1]
                if w[-1] <= curWeek and nflgame.find(playerInfo[0], team=None)[0].team == t and w[-1] in playerInfo[2]:
                    weeksPlayed1 = weeksPlayed1 - 1
                    break
        average = points / weeksPlayed
        return average
    elif playerInfo[0] != None:
        team = nflgame.standard_team(playerInfo[0])
        if team == None:
            return float('inf')
        playerInfo[0] = team
        points = fpDefense.fpDefense(playerInfo[0], playerInfo[1], playerInfo[2])
        weeksPlayed = nflgame.live.current_year_and_week()[1]
        curWeek = nflgame.live.current_year_and_week()[1]
        for w in byeWeekLists.byeWeeks:
            for t in w:
                if w[-1] <= curWeek and t == playerInfo[0] and w[-1] in playerInfo[2]:
                    weeksPlayed = weeksPlayed - 1
        return points / weeksPlayed
    else:
        return float('inf')
Ejemplo n.º 9
0
 def but():
     if not list1.currentItem():
         QMessageBox.critical(window,'error','Not league selected')
     else:
         defense = []
         ln=str(list1.currentItem().text())
         loopvar = QMessageBox.Yes
         rn,test = QInputDialog.getText(window,'New roster','Please enter the name for the new roster you\'d like to add:').strip()
         rn = str(rn)
         while loopvar == QMessageBox.Yes:
             dn,test = QInputDialog.getText(window,'Defense','Please enter a team to use as defense:').strip()
             if test:
                 d = nflgame.standard_team(str(dn))
                 if d is None:
                     QMessageBox.critical(window,'error','Invalid team name')
                 else:
                     defense.append(d)
                 if defense:
                     loopvar = QMessageBox.question(window,'???','Would you like to add another defense team?',QMessageBox.Yes|QMessageBox.No,QMessageBox.Yes)
             elif not defense:
                 QMessageBox.critical(window,'error','Cannot have no defense')
             else:
                 loopvar = QMessageBox.No
         status = fbTool.addRoster(ln,rn,defense)
         if status >=3:
             errstr = 'defense team ' + defense[status-3] + ' is already used'
             QMessageBox.critical(window,'error',errstr)
         elif status ==1:
             QMessageBox.critical(window,'error','Team already exists.')
         elif status:
             QMessageBox.critical(window,'error','Something is horribly wrong')
     mainMenu.updateTree()     
Ejemplo n.º 10
0
def addPlayer(leagueName, rosterName, playerName, playerTeam):
    if leagueLists:
        for l in leagueLists:
            if l.leagueName == leagueName:
                for r in l.rosters:
                    if r.rosterName == rosterName:
                        teamName = nflgame.standard_team(playerTeam)
                        playerFound = nflgame.find(playerName, team=teamName)
                        if playerFound:
                            p = playerFound[0]
                            plr2Ad = player(p.player_id, p.first_name, p.last_name, p.team, p.position)
                            for k in l.rosters:
                                if k.players:
                                    for j in k.players:
                                        if plr2Ad.firstName == j.firstName and plr2Ad.lastName == j.lastName and plr2Ad.team == j.team:
                                            return 1
                            r.players.append(plr2Ad)
                            return 0
                        else:   
                            return 2
                    elif r == l.rosters[-1]:
                        return 3
            elif l is leagueLists[-1]:
                return 4
    else:
        return 4
Ejemplo n.º 11
0
def find(name, season, team=None, pos=None,players=None):
    if players==None:
        players = nflgame.combine_game_stats(nflgame.games_gen(int(season)))
    indexed={}
    for p in players:
        indexed[p.playerid] = p
    if pos is not None:
        pos = standard_position(pos)

    result = []
    for pid, p in indexed.iteritems():
        if pos is not None and pos != standard_position(p.guess_position):
            continue

        r = edit_name(p, name)
        if r >= 0.8:
            result.append((r, pid))
    if len(result) == 0:
        return None

    result = heapq.nlargest(1, result)
    if team is not None and result[0][0] < 0.85:
        sameteam = lambda (r, pid): \
            nflgame.standard_team(team) == indexed[pid].team
        result = filter(sameteam, result)
        if len(result) == 0:
            return None
    #may need to for return of player object
    return nflgame.players[result[0][1]]
Ejemplo n.º 12
0
	def standard_team(team):
		teams=nflgame.standard_team()
		team = team.lower()
		for variants in teams:
			for variant in variants:
				if team == variant.lower():
					return variants[0]
					return None
Ejemplo n.º 13
0
def GetStdTeam(team):
    #Convert team name into easily parsable string
    tm = team.replace('-',' ')

    #Rams no longer in St. Louis (so just use Rams for search)
    if ("rams" in tm):
        tm = "rams"

    #Get standard team name
    stdteam = nflgame.standard_team(str(tm))
    return stdteam
Ejemplo n.º 14
0
 def download_projections_site(self, site, pos):
     """
     Method to download an individual site and position projection csv.
     """
     projections = {}
     #Set URL
     url = "https://rotogrinders.com/projected-stats/nfl-" + str(
         pos) + ".csv?site=" + str(site)
     #Use requests to download csv
     with requests.Session() as session:
         download = session.get(url)
         temp_list = download.content.decode('utf-8')
         #Process csv
         csv_reader = csv.reader(temp_list.splitlines(), delimiter=',')
         proj_list = list(csv_reader)
         #Process defense information
         if 'defense' in pos:
             for row in proj_list:
                 team = nflgame.standard_team(row[2])
                 if team is None:
                     team = self.PROJ_TEAM_CONV[row[2]]
                 key = str(team) + "-" + str(site)
                 salary = row[1]
                 proj = row[7]
                 floor = row[6]
                 ceiling = row[5]
                 projections[key] = (salary, proj, floor, ceiling)
         #Process offense information
         else:
             for row in proj_list:
                 name = row[0].split(" ")[1]
                 team = nflgame.standard_team(row[2])
                 if team is None:
                     team = self.PROJ_TEAM_CONV[row[2]]
                 key = str(name) + "-" + str(team) + "-" + str(site)
                 salary = row[1]
                 proj = row[7]
                 floor = row[6]
                 ceiling = row[5]
                 projections[key] = (salary, proj, floor, ceiling)
     return projections
Ejemplo n.º 15
0
def insert_spread(data):

    vegas_file = urllib.URLopener()
    vegas_file.retrieve(
        'http://xml.pinnaclesports.com/pinnaclefeed.aspx?sporttype=Football&sportsubtype=nfl',
        'week4/vegasodds.xml')
    tree = ElementTree.parse('week4/vegasodds.xml')

    for key, value in data.iteritems():

        for key, value in value.iteritems():

            # print key

            # odds
            root = tree.getroot()

            events = root[3]

            events = root.findall("./events/event")

            for event in events:

                participants = event.findall(
                    "./participants/participant/participant_name")

                for participant in participants:

                    current_team_name = nflgame.standard_team(participant.text)

                    if value['team'] == current_team_name:

                        if value['site'] == 'Home':

                            if event.find("./periods/period/spread/spread_home"
                                          ) is not None:
                                value['spread'] = event.find(
                                    "./periods/period/spread/spread_home").text
                            else:
                                value['spread'] = 'Not posted'
                        elif value['site'] == 'Away':

                            if event.find(
                                    "./periods/period/spread/spread_visiting"
                            ) is not None:
                                value['spread'] = event.find(
                                    "./periods/period/spread/spread_visiting"
                                ).text
                            else:
                                value['spread'] = 'Not posted'

    return data
Ejemplo n.º 16
0
    def update_players(self):
        print('Updating players...')

        for gsis_id in nflgame.players:
            # get the player object
            playerObj = nflgame.players[gsis_id]

            if playerObj.team and playerObj.position in ['QB', 'WR', 'TE', 'RB', 'FB', 'K']:
                # get nfl team
                team = NflTeam.objects.get(abbr=nflgame.standard_team(playerObj.team))

                try:
                    playerExists = NflPlayer.objects.get(gsis_id=playerObj.gsis_id, active=True)

                    # update team if different
                    if playerExists.team != team:
                        playerExists.team = team
                        #print('    Updating player team {}:{} ({})'.format(playerExists.gsis_id, playerExists.name, playerExists.team))
                        playerExists.save();

                except ObjectDoesNotExist:
                    # convert position
                    position = playerObj.position
                    if playerObj.position == 'FB':
                        position = 'RB'

                    # add player
                    player = NflPlayer.objects.create(
                        team = team,
                        gsis_id = playerObj.gsis_id,
                        name = playerObj.full_name,
                        position = position,
                        active = True
                    )
                    player.save()
                    #print('    Added player {}:{} ({})'.format(playerExists.gsis_id, playerExists.name, playerExists.team))

        for player in NflPlayer.objects.all():
            # if the player has no team
            if not nflgame.players[player.gsis_id].team:
                #print('    Deactivated player {}:{} ({})'.format(playerExists.gsis_id, playerExists.name, playerExists.team))
                player.active = False
                player.save()
Ejemplo n.º 17
0
def insert_spread(data):

    vegas_file = urllib.URLopener()
    vegas_file.retrieve('http://xml.pinnaclesports.com/pinnaclefeed.aspx?sporttype=Football&sportsubtype=nfl','week4/vegasodds.xml')
    tree = ElementTree.parse('week4/vegasodds.xml')

    for key, value in data.iteritems():

        for key, value in value.iteritems():

            # print key

            # odds
            root = tree.getroot()

            events = root[3]

            events = root.findall("./events/event")

            for event in events:

                participants = event.findall("./participants/participant/participant_name")

                for participant in participants:

                    current_team_name = nflgame.standard_team(participant.text)

                    if value['team'] == current_team_name:

                        if value['site'] == 'Home':

                            if event.find("./periods/period/spread/spread_home") is not None:
                                value['spread'] = event.find("./periods/period/spread/spread_home").text
                            else:
                                value['spread'] = 'Not posted'
                        elif value['site'] == 'Away':

                            if event.find("./periods/period/spread/spread_visiting") is not None:
                                value['spread'] = event.find("./periods/period/spread/spread_visiting").text
                            else:
                                value['spread']= 'Not posted'

    return data
Ejemplo n.º 18
0
def filter_ptp(ptp):
    #takes string of for 'First X Last X, Team Pos', 'First X Last X, Team Pos Pos', 'Team D/ST, TeamABV D/ST', Team D/ST, D/ST'
    # or 'TeamLoc Team' and converts it to (First Last, TeamABV, pos) or (Team D/ST, TeamABV, D/ST)
    ptp = re.split(",| ", ptp.replace('*', '').replace('/', ''))
    ptp = filter(
        lambda x: x not in [
            '', 'O', 'Q', 'P', 'D', 'SSPD', 'IR', 'Sr.', 'Jr.', 'I', 'II',
            'III', 'IV', 'V'
        ], ptp)

    if ptp[-2] in ['WR', 'RB']:
        #Account for multiposition players
        name, team, pos = ' '.join([ptp[0], ptp[-4]]), ptp[-3], ptp[-2]
        return (name, team, pos)
    elif ptp[-1] in ['QB', 'RB', 'WR', 'TE', 'K']:
        name, team, pos = ' '.join([ptp[0], ptp[-3]]), ptp[-2], ptp[-1]
        return (name, team, pos)
    else:
        #may need to filter to standard team
        dst = filter(lambda x: x in TEAMS, ptp)[0]
        return ('{} D/ST'.format(dst), nflgame.standard_team(dst), 'D/ST')
Ejemplo n.º 19
0
    def download_injury_status(self):
        """
        This method downloads injury status from pro football reference using pandas.
        """
        url = 'https://www.pro-football-reference.com/players/injuries.htm'
        html = requests.get(url).content
        df_list = pd.read_html(html)
        df = df_list[-1]
        injury_dict = {}
        team_list = []
        for index, row in df.iterrows():
            name = row["Player"]
            name = name.split(" ", 1)[1]
            team = nflgame.standard_team(row["Tm"])
            key = name + "-" + team
            injury_dict[key] = {
                'status': row["Class"],
                'details': row["Details"]
            }
        print("Injury status download complete")

        return injury_dict
Ejemplo n.º 20
0
def get_rush_yds_against_per_team(season=None, weeks=None):
    '''
    Returns a list of all teams and rushing yards scored against them (with at least 1 yard)
    '''
    if season == None and weeks == None:
        season, current_week = nflgame.live.current_year_and_week()
        weeks = [x for x in range(1, current_week + 1)]
    nfl_teams = nflgame.teams

    team_yds_against = []

    for team in nfl_teams:
        team_abbrev = nflgame.standard_team(team[0])
        result = get_rushing_yds_against(season, weeks, team_abbrev)

        if (result[1] > 0):
            # Only teams with yards against
            if isDebug:
                print "%s gave up %s rushing yds" % (result[0], result[1])
            team_yds_against.append(result)
    # Return list of receiving yds scored against this team
    return team_yds_against
Ejemplo n.º 21
0
def get_rush_yds_per_team(season=None, weeks=None):
    '''
    This returns all teams rushing yards for a season and week(s)
    '''
    if season == None and weeks == None:
        season, current_week = nflgame.live.current_year_and_week()
        weeks = [x for x in range(1, current_week + 1)]

    nfl_teams = nflgame.teams
    team_rec_yds = []

    for team in nfl_teams:
        team_abbrev = nflgame.standard_team(team[0])
        result = get_rushing_yds(season, weeks, team_abbrev)

        if (result[1] > 0):
            # Only teams with rushing yards
            if isDebug:
                print "%s had %s rushing yds" % (result[0], result[1])
            team_rec_yds.append(result)

    # Return list of teams and rushing yds
    return team_rec_yds
Ejemplo n.º 22
0
    def __init__(self, team):
        """
        Constructor
        Sets initial information
        """
        self.abbr = nflgame.standard_team(team)
        self.id = Team.TEAMS_ID[self.abbr]
        self.name = Team.TEAMS[self.abbr][1]
        self.conference = Team.TEAM_INFO[self.abbr][0]
        self.division = Team.TEAM_INFO[self.abbr][1]
        self.conf_div = self.conference + " " + self.division
        self.current_season = 0
        self.wins = 0
        self.losses = 0
        self.ties = 0
        self.streak = 0
        self.win_ratio = 1.0
        self.home = False
        self.opp = ''
        self.stadium = Team.TEAM_INFO[self.abbr][2]
        self.surface = Team.TEAM_INFO[self.abbr][3]

        self.data = pd.DataFrame(
            columns=Team.TEAM_HEADER.replace(' ', '').split(','))
Ejemplo n.º 23
0
 def update_info(self, team):
     """
     This method updates the teams information
     """
     self.abbr = nflgame.standard_team(team)
     self.name = Team.TEAMS[self.abbr][1]
Ejemplo n.º 24
0
    def add_game(self, game):
        """
        This method processes a game and updates the rankings.
        """
        #If the team exists in the dictionary update its values, else create new entry
        if nflgame.standard_team(game.home) in self.rushing_o:
            self.rushing_o[nflgame.standard_team(
                game.home)] += game.stats_home[3]
            self.passing_o[nflgame.standard_team(
                game.home)] += game.stats_home[2]
            self.scoring_o[nflgame.standard_team(game.home)] += game.score_home

            self.rushing_d[nflgame.standard_team(
                game.home)] += game.stats_away[3]
            self.passing_d[nflgame.standard_team(
                game.home)] += game.stats_away[2]
            self.scoring_d[nflgame.standard_team(game.home)] += game.score_away
        else:
            self.rushing_o[nflgame.standard_team(
                game.home)] = game.stats_home[3]
            self.passing_o[nflgame.standard_team(
                game.home)] = game.stats_home[2]
            self.scoring_o[nflgame.standard_team(game.home)] = game.score_home

            self.rushing_d[nflgame.standard_team(
                game.home)] = game.stats_away[3]
            self.passing_d[nflgame.standard_team(
                game.home)] = game.stats_away[2]
            self.scoring_d[nflgame.standard_team(game.home)] = game.score_away

        if nflgame.standard_team(game.away) in self.rushing_o:
            self.rushing_o[nflgame.standard_team(
                game.away)] += game.stats_away[3]
            self.passing_o[nflgame.standard_team(
                game.away)] += game.stats_away[2]
            self.scoring_o[nflgame.standard_team(game.away)] += game.score_away

            self.rushing_d[nflgame.standard_team(
                game.away)] += game.stats_home[3]
            self.passing_d[nflgame.standard_team(
                game.away)] += game.stats_home[2]
            self.scoring_d[nflgame.standard_team(game.away)] += game.score_home
        else:
            self.rushing_o[nflgame.standard_team(
                game.away)] = game.stats_away[3]
            self.passing_o[nflgame.standard_team(
                game.away)] = game.stats_away[2]
            self.scoring_o[nflgame.standard_team(game.away)] = game.score_away

            self.rushing_d[nflgame.standard_team(
                game.away)] = game.stats_home[3]
            self.passing_d[nflgame.standard_team(
                game.away)] = game.stats_home[2]
            self.scoring_d[nflgame.standard_team(game.away)] = game.score_home

        #Wrap dictionaries in OrderedDict to sort them
        self.rushing_o = OrderedDict(
            sorted(self.rushing_o.items(), key=lambda x: x[1], reverse=True))
        self.passing_o = OrderedDict(
            sorted(self.passing_o.items(), key=lambda x: x[1], reverse=True))
        self.scoring_o = OrderedDict(
            sorted(self.scoring_o.items(), key=lambda x: x[1], reverse=True))
        self.rushing_d = OrderedDict(
            sorted(self.rushing_d.items(), key=lambda x: x[1]))
        self.passing_d = OrderedDict(
            sorted(self.passing_d.items(), key=lambda x: x[1]))
        self.scoring_d = OrderedDict(
            sorted(self.scoring_d.items(), key=lambda x: x[1]))
Ejemplo n.º 25
0
    ind += 1

for i in range(START_YEAR, CUR_YEAR + 1):
    print "Processing " + str(i) + " season"
    for j in range(1, WEEKS_PER_YEAR + 1):
        try:
            if not (i == CUR_YEAR and j > CUR_WEEK):
                if (j <= REG_WEEKS):
                    games = nflgame.games(i, week=j, kind='REG')
                    #print "Processing Week " + str(j) + " of " + str(i) + " season"
                else:
                    games = nflgame.games(i, week=j - REG_WEEKS, kind='POST')
                    #print "Processing Postseason Week " + str(j-REG_WEEKS) + " of " + str(i) + " season"
                if len(games) > 0:
                    for game in games:
                        hname = nflgame.standard_team(game.home)
                        aname = nflgame.standard_team(game.away)
                        if (hname == "STL"):
                            hname = "LA"
                        if (aname == "STL"):
                            aname = "LA"
                        hteam = team_to_index[hname]
                        ateam = team_to_index[aname]
                        elos[hteam][j][i - START_YEAR], elos[ateam][j][
                            i - START_YEAR] = eloEval(
                                elos[hteam][j - 1][i - START_YEAR],
                                elos[ateam][j - 1][i - START_YEAR],
                                game.score_home, game.score_away,
                                streaks[hteam], streaks[ateam])
                        #update streaks
                        if game.score_home > game.score_away:
Ejemplo n.º 26
0
games = []

#weave them
while not(len(games1) == 0 and len(games2) == 0):
	if len(games1) > 0:
		games.append((games1[0], games1[1]))
		games1.pop(0)
		games1.pop(0)
	if len(games2) > 0:
		games.append((games2[0], games2[1]))
		games2.pop(0)
		games2.pop(0)
cache = []
for game in games:
	hname = nflgame.standard_team(game[1])
	aname = nflgame.standard_team(game[0])
	if(hname == "STL"):
		hname = "LA"
	if(aname == "STL"):
		aname = "LA"
	hteam = team_to_index[hname]
	ateam = team_to_index[aname]
	eloA = elos[hteam][WEEK][YEAR-START_YEAR] + H_TEAM_ADV
	eloB = elos[ateam][WEEK][YEAR-START_YEAR]
	Ea = 1/(1 + ELO_BASE**((eloB - eloA)/ELO_DIFF))
	Eb = 1/(1 + ELO_BASE**((eloA - eloB)/ELO_DIFF))
	diff = abs(Ea - Eb)
	if diff < 0.2:
		col = "cyan"
	elif diff < 0.4:
Ejemplo n.º 27
0
def split_csv_by_position(csvfile):
    reader = csv.reader(csvfile)
    head = next(reader)

    data = OrderedDict()

    for row in reader:
        position = row[0]
        name = row[1]
        salary = int(row[2])
        game_info = row[3]
        fppg = float(row[4])
        team = nflgame.standard_team(row[5])
        value = round(fppg / salary * 1000, 2)

        if '@' in game_info:
            home_team = nflgame.standard_team(
                game_info.split('@')[1].split(' ')[0])
            away_team = nflgame.standard_team(game_info.split('@')[0])
        else:
            home_team = None
            away_team = None

        if team == home_team:
            opponent = away_team
            site = 'Home'
        elif team == away_team:
            opponent = home_team
            site = 'Away'
        else:
            opponent = None
            site = None

        if position not in data:
            data[position] = OrderedDict()

        data[position][name] = OrderedDict()
        data[position][name]['salary'] = salary
        data[position][name]['fppg'] = fppg
        data[position][name]['value'] = value
        data[position][name]['team'] = team
        data[position][name]['opponent'] = opponent
        data[position][name]['floor'] = None
        data[position][name]['proj'] = None
        data[position][name]['cieling'] = None
        data[position][name]['proj value'] = None
        data[position][name]['site'] = site
        data[position][name]['spread'] = None
        data[position][name]['opp pa yds all'] = None
        data[position][name]['opp pa yds all/game'] = None
        data[position][name]['opp pa tds all'] = None
        data[position][name]['opp pa tds all/game'] = None
        data[position][name]['opp ru yds all'] = None
        data[position][name]['opp ru yds all/game'] = None
        data[position][name]['opp ru tds all'] = None
        data[position][name]['opp ru tds all/game'] = None
        # data[position][name]['player pa yds'] = None
        # data[position][name]['player pa yds/game'] = None
        # data[position][name]['player pa tds'] = None
        # data[position][name]['player pa tds/game'] = None
        # data[position][name]['player ru yds'] = None
        # data[position][name]['player ru yds/game'] = None
        # data[position][name]['player ru tds'] = None
        # data[position][name]['player ru tds/game'] = None
        # data[position][name]['player rec yds'] = None
        # data[position][name]['player rec yds/game'] = None
        # data[position][name]['player rec tds'] = None
        # data[position][name]['player rec tds/game'] = None
        data[position][name]['game info'] = game_info

    data = insert_projections(data)
    data = insert_spread(data)
    return data
Ejemplo n.º 28
0
 def setInfo(self, team):
     """
     Update team name
     """
     self.abbr = nflgame.standard_team(team)
Ejemplo n.º 29
0
def get_id(team):
    """
    Method to get id from team name
    """
    return Team.TEAMS_ID[nflgame.standard_team(team)]
Ejemplo n.º 30
0
		self.awayScore=awayScore
		self.homeTimeout=homeTimeout
		self.awayTimeout=awayTimeout


	def standard_team(team):
		teams=nflgame.standard_team()
		team = team.lower()
		for variants in teams:
			for variant in variants:
				if team == variant.lower():
					return variants[0]
					return None


homeTeam=nflgame.standard_team("texans")
awayTeam=nflgame.standard_team("broncos")

print homeTeam +" vs "+ awayTeam

game1= Game(homeTeam, awayTeam, 0,0,3,3)


class Drive:
	def __init__ (self, possession, player1, playType, receiver, yardage, touchdown,timeout, turnover):
			self.possession= possession
			self.player1= player1
			self.playType= playType
			self.receiver= receiver
			self.yardage= yardage
			self.touchdown= touchdown
Ejemplo n.º 31
0
Archivo: gen.py Proyecto: mabotkin/nfl
	ind += 1

for i in range(START_YEAR, CUR_YEAR + 1):
	print "Processing " + str(i) + " season"
	for j in range(1,WEEKS_PER_YEAR+1):
		try:
			if not (i == CUR_YEAR and j > CUR_WEEK):
				if(j <= REG_WEEKS):
					games = nflgame.games(i,week=j,kind='REG')
					#print "Processing Week " + str(j) + " of " + str(i) + " season"
				else:
					games = nflgame.games(i,week=j-REG_WEEKS,kind='POST')
					#print "Processing Postseason Week " + str(j-REG_WEEKS) + " of " + str(i) + " season"
				if len(games) > 0:
					for game in games:
						hname = nflgame.standard_team(game.home)
						aname = nflgame.standard_team(game.away)
						if(hname == "STL"):
							hname = "LA"
						if(aname == "STL"):
							aname = "LA"
						hteam = team_to_index[hname]
						ateam = team_to_index[aname]
						elos[hteam][j][i-START_YEAR], elos[ateam][j][i-START_YEAR] = eloEval(elos[hteam][j-1][i-START_YEAR], elos[ateam][j-1][i-START_YEAR], game.score_home, game.score_away, streaks[hteam], streaks[ateam])
						#update streaks
						if game.score_home > game.score_away:
							if streaks[hteam] >= 0:
								streaks[hteam] += 1
							else:
								streaks[hteam] = 0
							if streaks[ateam] <= 0:
Ejemplo n.º 32
0
    def __init__(self,
                 home,
                 away,
                 ranks,
                 schedule,
                 teams,
                 season,
                 week,
                 game=None):
        """
        Constructor
        Processes all information into the data frame
        """

        #Get home and away team
        self.home = teams[get_id(nflgame.standard_team(home))]
        self.away = teams[get_id(nflgame.standard_team(away))]

        #Get stadium and surface information
        self.stadium = self.home.stadium
        self.surface = self.home.surface

        #Check if game has completed
        if not game is None:
            self.score_home = game.score_home
            self.score_away = game.score_away
        else:
            self.score_home = 0
            self.score_away = 0
        #Get information from nflgame schedule
        id_string = str(self.home.id) + "-" + str(self.away.id)
        schedule_info = schedule[season][week][id_string]
        if 'meridiem' in schedule_info and schedule_info[
                'meridiem'] is not None:
            meridiem = schedule_info['meridiem']
        else:
            meridiem = 'PM'
        self.time_string = str(schedule_info['month']) + " " + str(
            schedule_info['day']) + " " + str(season) + " " + str(
                schedule_info['time']) + str(meridiem)
        self.game_time = schedule_info['time'].strip(":")
        self.game_day = schedule_info['wday']
        self.time = datetime.datetime.strptime(self.time_string,
                                               '%m %d %Y %I:%M%p')

        #Set game weather information
        if 'Fixed' not in self.stadium:
            self.weather = get_weather_data(season, week, self.away.name,
                                            self.home.name)
        else:
            self.weather = {
                'conditions': 'Clear',
                'temp': 72,
                'wind': 0,
                'humidity': 40,
                'visibility': 10,
                'barometric_pressure': 1013,
                'dew_point': 55
            }
        #Build data frame
        self.data = pd.DataFrame(
            columns=Game.GAME_HEADER.replace(' ', '').split(','))
        self.data_home = pd.DataFrame(
            columns=Game.GAME_HEADER_TEAM.replace(' ', '').split(','))
        self.data_away = pd.DataFrame(
            columns=Game.GAME_HEADER_TEAM.replace(' ', '').split(','))
        game_info = self.weather
        rank_info_home = ranks.get_ranks(nflgame.standard_team(self.away.abbr))
        rank_info_home['season'] = season
        rank_info_home['week'] = week
        rank_info_home['opp_conf'] = self.away.conference
        rank_info_home['opp_div'] = self.away.division
        rank_info_home['opp_div_conf'] = self.away.conf_div
        rank_info_home['opp_win_ratio'] = self.away.win_ratio
        rank_info_home['opp_streak'] = self.away.streak
        rank_info_home['win_ratio'] = self.home.win_ratio
        rank_info_away = ranks.get_ranks(nflgame.standard_team(self.home.abbr))
        rank_info_away['season'] = season
        rank_info_away['week'] = week
        rank_info_away['opp_conf'] = self.home.conference
        rank_info_away['opp_div'] = self.home.division
        rank_info_away['opp_div_conf'] = self.home.conf_div
        rank_info_away['opp_win_ratio'] = self.home.win_ratio
        rank_info_away['opp_streak'] = self.home.streak
        rank_info_away['win_ratio'] = self.away.win_ratio
        game_info['stadium'] = self.stadium
        game_info['surface'] = self.surface
        game_info['season'] = season
        game_info['week'] = week
        game_info['game_time'] = self.game_time
        game_info['game_day'] = self.game_day
        game_info['time'] = self.time
        self.data = self.data.append(game_info, ignore_index=True)
        self.data_team = {}
        self.data_team[get_id(nflgame.standard_team(
            self.home.abbr))] = self.data_home.append(rank_info_home,
                                                      ignore_index=True)
        self.data_team[get_id(nflgame.standard_team(
            self.away.abbr))] = self.data_away.append(rank_info_away,
                                                      ignore_index=True)
Ejemplo n.º 33
0
def generate_week_players():
    s, w = nflgame.live.current_year_and_week()

    week_players = get_json('nflleague/players.json', identity_player())
    nflgame_players = get_json(nflgame.player._player_json_file, {})
    if len(week_players) == 1:
        for pid, plyr in nflgame_players.iteritems():
            if plyr.get('team', False):
                team = plyr.get('team') if plyr.get('team') != 'JAC' else 'JAX'
                plyr['team'] = {str(s): {str(w): team}}
                plyr['position'] = {
                    str(s): {
                        str(w): plyr.get('position', 'NONE')
                    }
                }
            else:
                plyr['position'] = {}
                plyr['team'] = {}
            plyr['schedule'] = {}
            plyr['gsis_name'] = '.'.join(
                [plyr['first_name'][0], plyr['last_name']])
            week_players[pid] = plyr

    for season in range(2014, s + 1):
        for week in range(1, 18):
            if (season, week) == (s, w):
                break

            print(season, week)
            if str(season) in week_players['00-0000000']['team'].keys():
                if str(week) in week_players['00-0000000']['team'][str(
                        season)].keys():
                    continue
                    print('S:{}  W:{} passed'.format(season, week))
                else:
                    week_players['00-0000000']['team'][str(season)][str(
                        week)] = 'NA'
                    week_players['00-0000000']['position'][str(season)][str(
                        week)] = 'NA'
            else:
                week_players['00-0000000']['team'][str(season)] = {
                    str(week): 'NA'
                }
                week_players['00-0000000']['position'][str(season)] = {
                    str(week): 'NA'
                }

            games = nflgame.games(season, week=week)
            players = nflgame.combine_max_stats(games)
            for plyr in players:
                team = nflgame.standard_team(plyr.team)
                if plyr.name == 'A.Robinson':
                    print(plyr.name, week, team)
                if plyr.player != None:
                    position = guess_pos(plyr)
                    if str(season) not in week_players[
                            plyr.playerid]['team'].keys():
                        week_players[plyr.playerid]['team'][str(season)] = {
                            str(week): team
                        }
                        week_players[plyr.playerid]['position'][str(
                            season)] = {
                                str(week): position
                            }
                    else:
                        week_players[plyr.playerid]['team'][str(season)][str(
                            week)] = team
                        week_players[plyr.playerid]['position'][str(season)][
                            str(week)] = position

        #Fill in any unknown team weeks with most likely correct team
        for pid, plyr in week_players.iteritems():
            if type(plyr['team']) == dict and str(
                    season) not in plyr['team'].keys():
                continue
            if plyr.get('position', '') == 'D/ST':
                continue

            #Only 1 position per season, so find most commonly guessed position and set to all games.  For now
            count = collections.Counter()
            for pos in plyr['position'][str(season)].values():
                count[pos] += 1
            position = sorted(count.items(), key=lambda x: x[1],
                              reverse=True)[0][0]
            for i in range(1, 18):
                plyr['position'][str(season)][str(i)] = position

            #Fill in Teams
            act = []
            for week in range(1, 18):
                if str(week) in plyr['team'][str(season)].keys():
                    act.append(plyr['team'][str(season)][str(week)])
                else:
                    act.append(False)
            #Dont forget about the knile davis situation
            if not act[0]:
                T, index = False, 0
                while (not T):
                    T = act[index]
                    index += 1
                act[0] = T
                plyr['team'][str(season)]['1'] = T

            for i, team_week in enumerate(act, start=0):
                if not team_week:
                    plyr['team'][str(season)][str(i + 1)] = plyr['team'][str(
                        season)][str(i)]
            week_players[pid] = plyr

        #Build Defenses.  Defenses will have constant team and position
        for did in nflgame.teams:
            if did[0] not in week_players:
                week_players[did[0]] = {
                    "first_name": did[1],
                    "full_name": did[3],
                    "gsis_id": did[0],
                    "gsis_name": ' '.join([did[2], 'D/ST']),
                    "last_name": did[2],
                    "position": "D/ST",
                    "profile_url": "http://www.nfl.com/",
                    "team": did[0],
                    "schedule": {},
                    "status": 'ACT'
                }

        length = len(week_players)

        #Build game_eid dictionary
        for i, (pid, plyr) in enumerate(week_players.iteritems()):
            if type(plyr['team']) == dict and str(
                    season) not in plyr['team'].keys():
                #skip players who weren't statistically active
                continue
            week_players[pid]['schedule'][str(season)] = {}
            print(pid, plyr['full_name'],
                  '{}%'.format(round((float(i) / length) * 100, 2)))
            for week in range(1, 18):
                if plyr.get('position') != 'D/ST':
                    team = week_players[pid]['team'][str(season)][str(week)]
                else:
                    team = week_players[pid]['team']
                week_players[pid]['schedule'][str(season)][str(
                    week)] = load_schedule_info(season, week, team)

    save_json('nflleague/players.json', week_players)
Ejemplo n.º 34
0
    def update_games(self):
        print('Updating games:')
        for year, phase, week in update_sched.year_phase_week(year=self.year):
            if phase != 'PRE':
                print('    {} year: {}, week: {}'.format(phase, year, week))
                try:
                    for game in nflgame.games(year, week=week, kind=phase):

                    # for game in update_sched.week_schedule(year, phase, week):
                        # format the date
                        meridiem = game.schedule.get('meridiem') if game.schedule.get('meridiem') else 'PM'
                        year = game.schedule.get('year') if game.schedule.get('month') > 7 else game.schedule.get('year') + 1
                        time_string = str(year) + '-' + str(game.schedule.get('month')) + '-' + str(game.schedule.get('day')) + ' ' + str(game.schedule.get('time')) + str(meridiem)
                        start_time = datetime.strptime(time_string, '%Y-%m-%d %I:%M%p')

                        # setup the home and away teams
                        home_team = NflTeam.objects.get(abbr=nflgame.standard_team(game.schedule.get('home')))
                        away_team = NflTeam.objects.get(abbr=nflgame.standard_team(game.schedule.get('away')))

                        try:
                            # fetch game from game key
                            gameObj = NflGame.objects.get(game_key=game.schedule.get('gamekey'))

                            # update the start time
                            if gameObj.starts_at != start_time:
                                print('        Updating start_time {}: {}'.format(gameObj.game_key, start_time))
                                gameObj.starts_at = start_time
                                gameObj.save()

                        except NflGame.DoesNotExist:
                            # convert week
                            if phase == 'REG':
                                week = game.schedule.get('week') if week > 0 else 1
                            elif phase == 'POST':
                                week = game.schedule.get('week') + 17 if week > 0 else 18

                            # print('        Creating game {}: {} vs {} at {}'.format(game.schedule.get('gamekey'), home_team, away_team, start_time))
                            # create the game
                            gameObj = NflGame.objects.create(
                                week = week,
                                starts_at = start_time,
                                game_key = game.schedule.get('gamekey'),
                                game_id = game.schedule.get('eid'),
                                type = phase,
                                home_team = home_team,
                                away_team = away_team,
                            )
                            gameObj.save()

                        # update the winning and losing teams
                        print('        {} ({}) vs {} ({})'.format(home_team, game.score_home, away_team, game.score_away))
                        if(game.score_home >= game.score_away):
                            gameObj.winning_team = home_team
                            gameObj.losing_team = away_team
                        else:
                            gameObj.losing_team = home_team
                            gameObj.winning_team = away_team

                        # save the game update
                        gameObj.save()

                        # calculate score diffs
                        home_diff = game.score_home - game.score_away
                        away_diff = game.score_away - game.score_home

                        try:
                            stat = NflStat.objects.get(week=week, team=home_team.abbr)
                        except MultipleObjectsReturned:
                            print('{}: {}'.format(week, home_team.abbr))
                        except ObjectDoesNotExist:
                            stat = NflStat.objects.create(
                                week = week,
                                td = 0,
                                two = 0,
                                xp = 0,
                                fg = 0,
                                diff = home_diff,
                                team = home_team
                            )
                            stat.save()

                        # update/create away team stats
                        try:
                            stat = NflStat.objects.get(week=week, team=away_team.abbr)
                        except ObjectDoesNotExist:
                            stat = NflStat.objects.create(
                                week = week,
                                td = 0,
                                two = 0,
                                xp = 0,
                                fg = 0,
                                diff = away_diff,
                                team = away_team
                            )
                            stat.save()
                except TypeError:
                    pass
Ejemplo n.º 35
0
def standard_nfl_abv(team):
    if 'D/ST' in team.split():
        team=team.split()[0]
    return nflgame.standard_team(team)
Ejemplo n.º 36
0
import nflgame

choice = raw_input("what team? ")

team = nflgame.standard_team(choice)

games = nflgame.games(2014, home=team, away=team)

players = nflgame.combine_game_stats(games)

for p in players.passing().sort('passing_yds'):
    print p.team, p, p.passing_yds
Ejemplo n.º 37
0
def split_csv_by_position(csvfile):
    reader = csv.reader(csvfile)
    head = next(reader)

    data = OrderedDict()

    for row in reader:
        position = row[0]
        name = row[1]
        salary = int(row[2])
        game_info = row[3]
        fppg = float(row[4])
        team = nflgame.standard_team(row[5])
        value = round(fppg/salary*1000,2)

        if '@' in game_info:
            home_team = nflgame.standard_team(game_info.split('@')[1].split(' ')[0])
            away_team = nflgame.standard_team(game_info.split('@')[0])
        else:
            home_team = None
            away_team = None

        if team == home_team:
            opponent = away_team
            site = 'Home'
        elif team == away_team:
            opponent = home_team
            site = 'Away'
        else:
            opponent = None
            site = None

        if position not in data:
            data[position] = OrderedDict()

        data[position][name] = OrderedDict()
        data[position][name]['salary'] = salary
        data[position][name]['fppg'] = fppg
        data[position][name]['value'] = value
        data[position][name]['team'] = team
        data[position][name]['opponent'] = opponent
        data[position][name]['floor'] = None
        data[position][name]['proj'] = None
        data[position][name]['cieling'] = None
        data[position][name]['proj value'] = None
        data[position][name]['site'] = site
        data[position][name]['spread'] = None
        data[position][name]['opp pa yds all'] = None
        data[position][name]['opp pa yds all/game'] = None
        data[position][name]['opp pa tds all'] = None
        data[position][name]['opp pa tds all/game'] = None
        data[position][name]['opp ru yds all'] = None
        data[position][name]['opp ru yds all/game'] = None
        data[position][name]['opp ru tds all'] = None
        data[position][name]['opp ru tds all/game'] = None
        # data[position][name]['player pa yds'] = None
        # data[position][name]['player pa yds/game'] = None
        # data[position][name]['player pa tds'] = None
        # data[position][name]['player pa tds/game'] = None
        # data[position][name]['player ru yds'] = None
        # data[position][name]['player ru yds/game'] = None
        # data[position][name]['player ru tds'] = None
        # data[position][name]['player ru tds/game'] = None
        # data[position][name]['player rec yds'] = None
        # data[position][name]['player rec yds/game'] = None
        # data[position][name]['player rec tds'] = None
        # data[position][name]['player rec tds/game'] = None
        data[position][name]['game info'] = game_info

    data = insert_projections(data)
    data = insert_spread(data)
    return data