• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python nfldb.connect函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: week_choices

def week_choices(request):
    response_data = week_choices_dict()
    db = nfldb.connect()
    current_week = nfldb.current(db)
    response_data['current_year'] = current_week[1]
    response_data['current_week'] = current_week[2]
    return HttpResponse(json.dumps(response_data), content_type="application/json")
开发者ID:andyyc,项目名称:bloop,代码行数:7,代码来源:views.py


示例2: showStatDefense

def showStatDefense(team_input, week_input):
	statJSON = {}
	#STAT_STRING_LIST_DEFENSE=['defense_sk', 'defense_int', 'defense_frec', 'defense_safe', 'defense_frec_tds', 'defense_int_tds', 'defense_misc_tds', 'kickret_tds']
	stat_string_list = STAT_STRING_LIST_DEFENSE	
	stat_season_totals =  [0 for x in range(len(stat_string_list))]
	#stat_string_list = ['puntret_tds']	
	db = nfldb.connect()
	q = nfldb.Query(db)
	q.game(season_year=2012, season_type='Regular',  week=week_input, team=team_input)
		
	for p in q.as_games():				
		if p.away_team == team_input:
			statJSON['points_allowed']= p.home_score
		else:
			statJSON['points_allowed']= p.away_score
	
	#check for bye week all stats = 0
	if len(q.as_games())==0:
		team_home_away = 'bye'
		for index in xrange(len(stat_string_list)):
			statJSON[stat_string_list[index]] = 0
		return statJSON
	
	for index in xrange(len(stat_string_list)):
			stat = showStat(stat_string_list[index], team_input, week_input)
			statJSON[stat_string_list[index]] = stat
			#stat_season_totals[index] +=stat	
	
	statJSON['defense_touchdowns'] = statJSON['defense_int_tds'] + statJSON['defense_frec_tds'] + statJSON['defense_misc_tds']
	#	for key, index in statJSON.items():	
		#print ("Totals Week: " +str(week_input) + " " + team_input + " " + key+ " "+ str(index) + '\n')	
	return statJSON
开发者ID:christopherfan,项目名称:IOLab_NFL,代码行数:32,代码来源:generateTeamStats.py


示例3: playerstats

 def playerstats(self, **kwargs):
     player = kwargs['player']
     db = nfldb.connect()
     q = nfldb.Query(db)
     q.game(season_year=kwargs['season'], season_type='Regular')
     if kwargs['targtype'] == "non-redzone":
         pos1 = nfldb.FieldPosition.from_str('OWN 1')
         pos2 = nfldb.FieldPosition.from_str('OPP 21')
     #OPP 20 to OPP 10 yardline
     elif kwargs['targtype'] == 'redzone':
         pos1 = nfldb.FieldPosition.from_str('OPP 20')
         pos2 = nfldb.FieldPosition.from_str('OPP 11')
     #OPP 10 to OPP 6
     elif kwargs['targtype'] == 'goaline1':
         pos1 = nfldb.FieldPosition.from_str('OPP 10')
         pos2 = nfldb.FieldPosition.from_str('OPP 6')
     # OPP 5 to OPP 3
     elif kwargs['targtype'] == 'goaline2':
         pos1 = nfldb.FieldPosition.from_str('OPP 5')
         pos2 = nfldb.FieldPosition.from_str('OPP 3')
     #OPP 2 or OPP 1
     elif kwargs['targtype'] == 'goaline3':
         pos1 = nfldb.FieldPosition.from_str('OPP 2')
         pos2 = nfldb.FieldPosition.from_str('OPP 1')
     
     q.play(yardline__ge=pos1)
     q.play(yardline__le=pos2)
     q.player(full_name= player)
     for pp in q.as_aggregate():
         return pp
开发者ID:bzitz,项目名称:awesomeproject,代码行数:30,代码来源:stats.py


示例4: showPlayerStat

def showPlayerStat(player_ID, week_input):
	statJSON={}	
	stat_string_list = STAT_STRING_LIST
	
	db = nfldb.connect()
	q = nfldb.Query(db)
		
	q.game(season_year=2012, season_type='Regular',  week=week_input)	
	q.player(player_id=player_ID)
	
	# for p in q.sort([('gsis_id', 'asc'), ('time', 'asc')]).as_plays():
		# print p	
	
	for p in q.as_aggregate():
		
		for index in xrange(len(stat_string_list)):
			key = stat_string_list[index]
			value = eval('p.'+stat_string_list[index])
			statJSON[key]=value
			#print key, value
	#Check for empty week stat due to BYE week
	if len(q.as_aggregate() )==0:
		for index in xrange(len(stat_string_list)):
			key = stat_string_list[index]			
			statJSON[key]=0	
	return statJSON
开发者ID:christopherfan,项目名称:IOLab_NFL,代码行数:26,代码来源:generateTeamStats.py


示例5: getOpponent

def getOpponent(team_input, week_input):
	statJSON = {}
	STAT_STRING_OPPONENT = ['passing_yds', 'passing_tds',  'rushing_yds','receiving_yds', 'receiving_tds' ,'kickret_tds', 'fumbles_rec_tds','rushing_tds']	
	stat_string_list = STAT_STRING_OPPONENT
	stat_season_totals =  [0 for x in range(len(stat_string_list))]
	#stat_string_list = ['puntret_tds']	
	db = nfldb.connect()
	q = nfldb.Query(db)
	q.game(season_year=2012, season_type='Regular',  week=week_input, team=team_input)

	#check for bye week all stats = 0
	if len(q.as_games())==0:
		team_home_away = 'bye'
		statJSON['opponent']= 'bye'
		for index in xrange(len(stat_string_list)):
			statJSON[stat_string_list[index]+'_allowed'] = 0		
		return statJSON
	
	for p in q.as_games():				
		if p.away_team == team_input:
			opponent = p.home_team
		else:
			opponent = p.away_team
		statJSON['opponent'] = opponent
		#print "Team: ", team_input, " has Opponent: ", opponent
	
	q.game(season_year=2012, season_type='Regular',  week=week_input, team=opponent)	
	for p in q.as_games():					
		for index in xrange(len(stat_string_list)):
				stat = showStat(stat_string_list[index], opponent, week_input)
				statJSON[stat_string_list[index]+'_allowed'] = stat
				stat_season_totals[index] +=stat	
	
	#print statJSON
	return statJSON
开发者ID:christopherfan,项目名称:IOLab_NFL,代码行数:35,代码来源:generateTeamStats.py


示例6: makeWinMatrix

def makeWinMatrix(players):

    db = nfldb.connect()

    # Get number of players in list
    size = len(players)
    playerInd = {}

    ind = 0

    print '\n index\tname'
    for x in players:
        x = x.split(' (')
        print str(ind) + '\t' + x[0]

        qd = nfldb.Query(db)
        qd.game(season_year=2015, season_type='Regular')
        pp = qd.player(full_name=x[0]).as_aggregate()
        for x in pp:
            playerInd[ind] = x
        ind += 1

    xcord = 0

    allWins = []
    allLoses = []
    while xcord < size - 1:
        winsList = []
        losesList = []
        check = playerInd[xcord]
        loses = 0
        ycord = 0
        while ycord < size - 1:
            losesList.append(0)
            if ycord != xcord:
                against = playerInd[ycord]
                wins, loses = calcWins(check, against, loses)
                winsList.append(wins)
            else:
                winsList.append(0)

            ycord += 1
        losesList[xcord] = loses
        rowWins = numpy.array([winsList])
        rowLoses = numpy.array([losesList])

        allWins.append(rowWins)
        allLoses.append(rowLoses)

        xcord += 1

    matrixWins = numpy.vstack(allWins)
    matrixLoses = numpy.vstack(allLoses)
    print '---------- Wins ----------'
    print(matrixWins)
    print '---------- Loses ----------'
    print(matrixLoses)

    return matrixWins, matrixLoses
开发者ID:dFed17,项目名称:fantasyOptimizer,代码行数:59,代码来源:functions.py


示例7: games_played

 def games_played(self,player,year):
     db = nfldb.connect()
     q = nfldb.Query(db)
     q.game(season_year=year, season_type='Regular',)
     q.player(full_name=player)
     if q.as_games() != None:
         return len(q.as_games())
     else:
         return 0
开发者ID:bzitz,项目名称:awesomeproject,代码行数:9,代码来源:stats.py


示例8: __init__

    def __init__(self, name, seasonyear):
        self.__name = name
        self.__seasonYear = seasonyear
        __nfldbConnect = nfldb.connect()

        q = nfldb.Query(__nfldbConnect).game(season_year=self.__seasonYear, season_type='Regular')
        for pp in q.as_aggregate():
            print pp.player
        return
开发者ID:Donhescht,项目名称:NFL-Development,代码行数:9,代码来源:NFLPlayer.py


示例9: __init__

 def __init__(self, name = "Team", short_name = "UNK", year = 2009):
     self.name = name
     self.short_name = short_name
     self.possession = False
     self.year = year
     self.db = nfl.connect()
     self.q = nfl.Query(self.db)
     self.q.player(team=short_name)
     self.roster = self.q.as_aggregate()
     print self.name
开发者ID:CaldwellYSR,项目名称:FootballSim,代码行数:10,代码来源:Team.py


示例10: testCheck

 def testCheck(self):
     return
     db = nfldb.connect()
     calc = Trade.Calculator(PURE)
     q = nfldb.Query(db)
     q.game(season_year=2009, season_type='Regular')
     rushers = q.sort('rushing_yds').limit(100).as_aggregate()
     receivers = q.sort('receiving_yds').limit(100).as_aggregate()
     passers = q.sort('passing_yds').limit(35).as_aggregate()
     players = Trade.aggpps_to_players(rushers + receivers + passers)
     for rec,yds in calc.sort_position_more(players, 'TE'):
         print "{} {}".format(rec,yds)
开发者ID:eapeyton,项目名称:tradeaide,代码行数:12,代码来源:TradeTest.py


示例11: query_players_by_year

    def query_players_by_year(self, year):
        db = nfldb.connect()
        q = nfldb.Query(db)
        q.game(season_year=year, season_type='Regular')

        # Only retrieving a limited amount to avoid more manual position tagging
        rushers = q.sort('rushing_yds').limit(100).as_aggregate()
        receivers = q.sort('receiving_yds').limit(100).as_aggregate()
        passers = q.sort('passing_yds').limit(35).as_aggregate()

        players = self.aggpps_to_players(rushers + receivers + passers)
        return players
开发者ID:eapeyton,项目名称:tradeaide,代码行数:12,代码来源:Trade.py


示例12: get_weeklypts

def get_weeklypts(team, week, year):
    players = []
    db = nfldb.connect()
    q = nfldb.Query(db)
    q.game(season_year=year, season_type='Regular', team=team, week=week )
    for p in q.as_players():
        if p.team == team and p.team != "UNK":  
            pts = get_weeklypoints(year,p.full_name, week)
            if pts != 0:
                players.append((p.full_name,str(p.position),str(p.team), week, pts)) 
                
    return players
开发者ID:bzitz,项目名称:awesomeproject,代码行数:12,代码来源:top-ten-qbs.py


示例13: module1

def module1():

	db = nfldb.connect()
	q = nfldb.Query(db)
	q.game(season_year=2013, season_type='Regular')
	
	for pp in q.sort('passing_yds').limit(10).as_aggregate():
		print pp.player, pp.passing_yds
	
	q.player(full_name="Tom Brady").play(passing_tds=1)	
	for play in q.as_plays():
		print play
开发者ID:christopherfan,项目名称:IOLab_NFL,代码行数:12,代码来源:top-ten-qbs.py


示例14: nfldb

def nfldb(year = 2013):
    import nfldb
    db = nfldb.connect()
    q = nfldb.Query(db)

    q.game(season_year=year, season_type='Regular')
    for pp in q.sort('passing_yds').limit(15).as_aggregate():
        print pp.player, pp.passing_yds, pp.rushing_tds

    print "\n"

    for pp in q.sort('rushing_yds').limit(15).as_aggregate():
        print pp.player, pp.rushing_yds, pp.rushing_tds
开发者ID:mirajsanghvi,项目名称:nfl_game_db,代码行数:13,代码来源:nfl_data.py


示例15: index

def index(request, year=0, week=0, season_type='Regular'):
    db = nfldb.connect()
    current = nfldb.current(db)
    if year == 0:
        season_type, year, week = nfldb.current(db)
        return redirect('index', year, season_type.name, week)
    q = nfldb.Query(db).game(
        season_year=year,
        season_type=season_type,
        week=week).sort('start_time')
    games = q.as_games()
    return render(request, 'games/index.html',
                  {'games_list': games, 'current': current, 'year': year})
开发者ID:Incipire,项目名称:FantasySportCenter,代码行数:13,代码来源:views.py


示例16: testAggPPToPlayer

    def testAggPPToPlayer(self):
        playerDB = Trade.PlayerDB()
        db = nfldb.connect()
        q = nfldb.Query(db)
        q.game(gsis_id='2009091000')

        player1 = q.sort('passing_yds').limit(1).as_aggregate()[0]
        self.assertEqual(playerDB.aggpp_to_player(player1), self.test_player1)

        player2 = q.sort('rushing_yds').limit(1).as_aggregate()[0]
        self.assertEqual(playerDB.aggpp_to_player(player2), self.test_player2)
        
        player_list = [player1, player2]
        self.assertEqual(playerDB.aggpps_to_players(player_list), 
                        [self.test_player1, self.test_player2])
开发者ID:eapeyton,项目名称:tradeaide,代码行数:15,代码来源:TradeTest.py


示例17: player_detail

def player_detail(request, player_id):
    db = nfldb.connect()
    player = nfldb.Player.from_id(db, player_id)

    if (player is None):
        raise Http404
    player_games = get_player_stats_by_game(player_id, db)
    player_seasons = get_player_stats_by_season(player_id, db)
    template = select_player_template(player)
    return render(request, template,
                  {
                      'player': player,
                      'player_games': player_games,
                      'player_seasons': player_seasons
                  })
开发者ID:Incipire,项目名称:FantasySportCenter,代码行数:15,代码来源:views.py


示例18: get_ptsagainst

def get_ptsagainst(team, year):
    db = nfldb.connect()
    q = nfldb.Query(db)
    results = []
    q.game(season_year=year, season_type='Regular', team=team )
    for game in q.as_games():
        if game.finished:
            if game.home_team == team:
                opp = game.away_team
            elif game.away_team == team:
                opp = game.home_team
            players = get_weeklypts(opp,game.week,year)
            for x in players:
                results.append(x)
    return results
开发者ID:bzitz,项目名称:awesomeproject,代码行数:15,代码来源:top-ten-qbs.py


示例19: main

def main(season_year):
    db = nfldb.connect()

    q = nfldb.Query(db).game(season_year=season_year, season_type='Postseason')

    team_file = 'playoff_' + str(season_year+1) + '_team_master.json'
    with open(team_file) as f:    
        teams = json.load(f)

    point_file = 'playoff_' + str(season_year+1) + '_point_key.json'
    with open(point_file) as f:    
        point_key = json.load(f)

    add_points_to_teams(db, teams, point_key, write_time=False)

    write_json(teams, write_dir='teams_'+str(season_year+1), write_time=False)
开发者ID:rboberg,项目名称:2degen1gen,代码行数:16,代码来源:playoff_2016_scoring.py


示例20: game_detail

def game_detail(request, gsid):
    db = nfldb.connect()
    q = nfldb.Query(db).game(gsis_id=gsid)
    games = q.as_games()
    if (len(games) != 1):
        raise Http404
    game = games[0]
    year = game.season_year
    week = game.week
    season_type = game.season_type
    games = nfldb.Query(db).game(
        season_year=year,
        season_type=season_type,
        week=week).sort('start_time').as_games()
    q.player(team=game.away_team)
    away_pass = q.aggregate(passing_att__gt=0).sort(
        'passing_yds').as_aggregate()
    home_pass = nfldb.Query(db).game(
        gsis_id=gsid).player(
        team=game.home_team).aggregate(
        passing_att__gt=0).sort('passing_yds').as_aggregate()
    home_rec = nfldb.Query(db).game(
        gsis_id=gsid).player(
        team=game.home_team).aggregate(
        receiving_rec__gt=0).sort('receiving_yds').as_aggregate()
    away_rec = nfldb.Query(db).game(
        gsis_id=gsid).player(
        team=game.away_team).aggregate(
        receiving_rec__gt=0).sort('receiving_yds').as_aggregate()
    away_run = nfldb.Query(db).game(
        gsis_id=gsid).player(
        team=game.away_team).aggregate(
        rushing_att__gt=0).sort('rushing_yds').as_aggregate()
    home_run = nfldb.Query(db).game(
        gsis_id=gsid).player(
        team=game.home_team).aggregate(
        rushing_att__gt=0).sort('rushing_yds').as_aggregate()
    return render(request, 'games/detail.html',
                  {'game': game,
                   'away_run': away_run,
                   'home_run': home_run,
                   'away_pass': away_pass,
                   'home_pass': home_pass,
                   'home_rec': home_rec,
                   'away_rec': away_rec,
                   'games': games,
                   })
开发者ID:Incipire,项目名称:FantasySportCenter,代码行数:47,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python nflgame.games函数代码示例发布时间:2022-05-27
下一篇:
Python nfe.ProcessadorNFe类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap