当前位置: 首页>>代码示例>>Python>>正文


Python nflgame.games函数代码示例

本文整理汇总了Python中nflgame.games函数的典型用法代码示例。如果您正苦于以下问题:Python games函数的具体用法?Python games怎么用?Python games使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了games函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fetch_defense_stats

def fetch_defense_stats():
    # team defense statistics
    statistics = {}
    for team in map(lambda x: x[0], nflgame.teams):
        statistics[team] = create_empty_entry()

    for year in range(2009, 2015):
        for week in range(1, 18):
            for game in nflgame.games(year=year, week=week):
                home = game.home
                away = game.away
                statistics[home][str(year)][str(week)] = {
                    'home': home,
                    'away': away,
                    'points_allowed': game.score_away,
                    'passing_yards_allowed': game.stats_away[2],
                    'rushing_yards_allowed': game.stats_away[3],
                    'turnovers': game.stats_away[6],
                    'played': True

                }
                statistics[away][str(year)][str(week)] = {
                    'home': home,
                    'away': away,
                    'points_allowed': game.score_home,
                    'passing_yards_allowed': game.stats_home[2],
                    'rushing_yards_allowed': game.stats_home[3],
                    'turnovers': game.stats_home[6],
                    'played': True
                }

    return statistics
开发者ID:romanlutz,项目名称:fantasy-football-prediction,代码行数:32,代码来源:get_data.py

示例2: raw_nfl_data_out

def raw_nfl_data_out():
    print "%s,%s,%s,%s,%s,%s,%s,%s" % ( "season","week","gametype","home","home_score","away","away_score","home_score_margin" )
    for s in y:
            for k in gametype:
                    games = nfl.games(s,kind=k)
                    for g in games:
                        print "%i, %i, %s, %s, %i, %s, %i, %i" % (g.season(), g.schedule['week'],k ,g.home,g.score_home,g.away,g.score_away,g.score_home-g.score_away)
开发者ID:sbollinger,项目名称:NFL-ML,代码行数:7,代码来源:nfl_ml.py

示例3: getPlayerStats

def getPlayerStats(plyr,stat): 
	game = nflgame.games(2012,week=[2,3,4,6])
	players = nflgame.combine(game)
	player = players.name(plyr)
	playerStats = player.stats
	if stat in playerStats:
		print 'stat: ',stat,' value = ',playerStats[stat]
开发者ID:JGx,项目名称:FantasyFootballViz,代码行数:7,代码来源:nfl.py

示例4: away_rushing_tds_in_year

def away_rushing_tds_in_year(year, player, team):
    avg = 0.0
    away_games = nflgame.games(year, home=team)
    players = nflgame.combine(away_games)
    this_player = players.name(player)
    avg += this_player.rushing_tds
    print year, this_player, this_player.rushing_tds, (avg / 8)
开发者ID:dawkterdan,项目名称:nfl,代码行数:7,代码来源:csvs.py

示例5: fetch_games

def fetch_games(year, week, team = None):
    games = nflgame.games(year, week)
    if team:
        for game in games:
            if game.home == team or game.away == team:
                return [ game ]
    return games
开发者ID:benderTheCrime,项目名称:playbyplay,代码行数:7,代码来源:app.py

示例6: get_game_data

def get_game_data(name, team, book, year):

    if __name__ == '__main__':
        try:
            player = nflgame.find(name)[0]
        except BaseException:
            return

    if '(, )' in str(player):
        print ("Player Inactive, or Player Not Found\n\n")
        return

    print ("*" *79)
    print (player)

    data = create_csv(player)
    data.append_separator(name)

    print (str(year) + '\n')
    data.append_separator(year)
    games = nflgame.games(year, home=team, away=team)
    for game in games:
        plyr = game.players.name(player.gsis_name)
        print ('-'*79)
        print (game)
        to_csv(data, plyr, game, year, player.position)

    with open(name + '.xls', 'wb') as f:
        f.write(data.xls)
    book.add_sheet(data)
开发者ID:darthfrazier,项目名称:PythonNFLStatScraper,代码行数:30,代码来源:scraper.py

示例7: _get_stats

def _get_stats(season, week, kind):
    """
    Memoized stats getter. Requires fully-specified arguments to make effective
    use of the cache.
    """
    games = nflgame.games(season, week=week, kind=kind)
    return nflgame.combine_max_stats(games)
开发者ID:jnu,项目名称:FantasyFootball,代码行数:7,代码来源:nflgame_dump.py

示例8: home_passing_tds_in_year

def home_passing_tds_in_year(year, player, team):
    avg = 0.0
    home_games = nflgame.games(year, home=team)
    players = nflgame.combine(home_games)
    this_player = players.name(player)
    avg += this_player.passing_tds
    print year, this_player, this_player.passing_tds, (avg / 8)
开发者ID:dawkterdan,项目名称:nfl,代码行数:7,代码来源:csvs.py

示例9: make_team_stats

 def make_team_stats(self):
     """
     Collect all stats for a given year, week(s), team(s).
     """
     for year in self.year:
         for week in self.week:
             if year < CURRENT_YEAR or (year == CURRENT_YEAR and week <= CURRENT_WEEK):
                 games = ng.games(year, week)
                 for game in games:
                     if 'home' in self.site and game.home in self.which_team:
                         home_team = self.teams[game.home][year][week]
                         home_team['OWN']['game'] = game
                         home_team['OWN']['OPP'] = game.away
                         home_team['OWN']['pts'] = game.score_home
                         home_team['OPP']['pts'] = game.score_away
                         home_team['OWN_TOTAL']['OPP'] = game.away
                         self.add_defense_stats(game.home, year, week, game)
                         self.add_passing_stats(game.home, year, week, game)
                         self.add_rushing_stats(game.home, year, week, game)
                     if 'away' in self.site and game.away in self.which_team:
                         away_team = self.teams[game.away][year][week]
                         away_team['OWN']['game'] = game
                         away_team['OWN']['OPP'] = '@ ' + game.home
                         away_team['OWN']['pts'] = game.score_away
                         away_team['OPP']['pts'] = game.score_home
                         away_team['OWN_TOTAL']['OPP'] = game.home
                         self.add_defense_stats(game.away, year, week, game)
                         self.add_passing_stats(game.away, year, week, game)
                         self.add_rushing_stats(game.away, year, week, game)
开发者ID:brettpilch,项目名称:nflstats,代码行数:29,代码来源:nflstats.py

示例10: create_all_players

def create_all_players(host, port, year, kind, game_weeks):
  games = []
  for week in game_weeks:
    for game in nflgame.games(year, week = week, kind = kind):
      games.append(Game(game, week))

  if not games:
    raise RuntimeError("Couldn't find any {}-games in {}, did you get the year right?".format(kind, year))

  offensive_players = {}
  defensive_players = {}

  for game in games:
    for player in game.offensive_players():
      if player.playerid not in offensive_players:
        offensive_players[player.playerid] = player
    for player in game.defensive_players():
      if player.team not in defensive_players:
        defensive_players[player.team] = player

  all_players = dict(offensive_players.items() + defensive_players.items())
  total_no_players = len(all_players.keys())
  counter = 1
  for key, value in all_players.iteritems():
    print "Uploading player "+value.name+" "+str(counter)+"/"+str(total_no_players)
    response = value.get_api_facade(host, port).create()
    if response.status_code != 200:
      print "Error creating player "+player.name+" code was "+str(response.status_code)
    counter += 1
开发者ID:Sighillrob,项目名称:shakitz-fantasy-football,代码行数:29,代码来源:__init__.py

示例11: main

def main():
    # Necessary lists
    seasonList, seasons, score, firstDowns, totalYards, passingYards, rushingYards, penaltyCount, penaltyYards, \
    turnovers, puntCount, puntYards, puntAverage = [], [], [], [], [], [], [], [], [], [], [], [], []
    # Creates each season
    for x in range(0,8):
        seasonListIteration = nflgame.games(x+2009)
        seasons += [x+2009 for y in range (0, len(seasonListIteration))]
        seasonList += seasonListIteration
    # Populates lists for each season
    for x in seasonList:
        score += [x.score_home, x.score_away]
        firstDowns += [x.stats_home.first_downs, x.stats_away.first_downs]
        totalYards += [x.stats_home.total_yds, x.stats_away.total_yds]
        passingYards += [x.stats_home.passing_yds, x.stats_away.passing_yds]
        rushingYards += [x.stats_home.rushing_yds, x.stats_away.rushing_yds]
        penaltyCount += [x.stats_home.penalty_cnt, x.stats_away.penalty_cnt]
        penaltyYards += [x.stats_home.penalty_yds, x.stats_away.penalty_yds]
        turnovers += [x.stats_home.turnovers, x.stats_away.turnovers]
        puntCount += [x.stats_home.punt_cnt, x.stats_away.punt_cnt]
        puntYards += [x.stats_home.punt_yds, x.stats_away.punt_yds]
        puntAverage += [x.stats_home.punt_avg, x.stats_away.punt_avg]
    # Writes .CSV with format Score, First Downs, Total Yards, Passing Yards, Rushing Yards, Penalty Count,
    # Penalty Yards, Turnovers, Punt Count, Punt Yards, Punt Average
    with open('NFL Stats Rewrite.csv', 'wb') as csvfile:
        gameWriter = csv.writer(csvfile, delimiter=',', quotechar=',', quoting=csv.QUOTE_MINIMAL)
        gameWriter.writerow(['Score', 'First Downs', 'Total Yards', 'Passing Yards', 'Rushing Yards', 'Penalty Count',
                             'Penalty Yards', 'Turnovers', 'Punt Count', 'Punt Yards', 'Punt Average'])
        for x in range(0, len(score)):
            gameWriter.writerow(
                [score[x], firstDowns[x], totalYards[x], passingYards[x], rushingYards[x], penaltyCount[x],
                 penaltyYards[x], turnovers[x], puntCount[x], puntYards[x], puntAverage[x]])
开发者ID:2001jiang,项目名称:NFL,代码行数:32,代码来源:NFLGame+to+CSV.py

示例12: get_games

def get_games(years):
    """
    Given a list of N years, N .csv files will be written,
    each containing game data for the regular season of that year.
    """
    for year in years:
        f = file('games/games_%s.csv' % year, 'w')
        print_header(f)

        games = nflgame.games(int(year))
        for game in games:
            home_team = game.home
            home_score = game.score_home
            away_team = game.away
            away_score = game.score_away
            week = game.schedule['week']

            f.write(
                '%s,%s,%d,%d,%d,%d\n' %
                (year, home_team, 1, week, home_score, away_score)
            )
            f.write(
                '%s,%s,%d,%d,%d,%d\n' %
                (year, away_team, 0, week, away_score, home_score)
            )
        f.close()
开发者ID:kendricktang,项目名称:homefieldadvantage,代码行数:26,代码来源:make_game_files.py

示例13: current_week

def current_week():
    # returns current week of season
    year = date.today().year
    for x in range(1, 18):
        games = nflgame.games(year, week=x, home=None, away=None, kind='REG', started=False)
        if games == []:
            return x-1
开发者ID:jakesyl,项目名称:fantasy-football,代码行数:7,代码来源:schedule.py

示例14: getSeasonStats

	def getSeasonStats(self, plyr, stat, season):   
		data = []
		# if season == 2014:
		# 	print "HERE"
		for x in range(1, 18):
			game = nflgame.games(season,week=x)
			if game == []:
				break
			players = nflgame.combine_game_stats(game)
			player = players.name(plyr)
			if player is None:
				data.append({'week':str(x),'active':'false'})
			else:
				playerStats = player.stats
				week_obj = {'week':str(x)}
				if(stat == 'all'):
					for x in playerStats:
						week_obj[x] = playerStats[x]
					week_obj['active'] = 'true'
					data.append(week_obj)
					# if season == 2014:
					# 	print week_obj
				else:
					data.append({'week':str(x),stat:str(playerStats[stat]), 'active':'true'})
		return data
开发者ID:JGx,项目名称:FantasyFootballViz,代码行数:25,代码来源:updateStats.py

示例15: getNextQuestion

    def getNextQuestion(self, cfg):
        while True:
            week = random.randrange(self._firstWeek, self._lastWeek+1)
            year = random.randrange(self._firstYear, self._thisYear+1)
            print year, week
            try:
                games = nflgame.games(year, week=week)
                g = random.randrange(0, len(games))
                game = games[g]
                if game.score_away_q5 > 0 or game.score_home_q5 > 0:
                    continue

                self.homeTeam = game.home
                self.awayTeam = game.away
                self.gameDate = datetime.datetime(game.schedule['year'], game.schedule['month'], game.schedule['day'])
                self.gameTime = game.schedule['time']

                self.homeScores = [game.score_home_q1, game.score_home_q2, game.score_home_q3, game.score_home_q4]
                self.awayScores = [game.score_away_q1, game.score_away_q2, game.score_away_q3, game.score_away_q4]
                self.homeFinalScore = game.score_home
                self.awayFinalScore = game.score_away

                break
            except:
                pass
        return self
开发者ID:jadamwilson2,项目名称:MathFlash,代码行数:26,代码来源:fbBoxScoreWidget.py


注:本文中的nflgame.games函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。