Beispiel #1
0
def test():
    team_id = TEAMS['ATL']['id']
    player_id = get_player('Lebron', 'James')
    assert team.TeamList()
    assert team.TeamSummary(team_id)
    team_details = team.TeamDetails(team_id)
    assert team_details
    assert team_details.background()
    assert team_details.history()
    assert team.TeamCommonRoster(team_id)
    assert team.TeamGeneralSplits(team_id)
    assert team.TeamOpponentSplits(team_id)
    assert team.TeamLastNGamesSplits(team_id)
    assert team.TeamInGameSplits(team_id)
    assert team.TeamClutchSplits(team_id)
    assert team.TeamShootingSplits(team_id)
    assert team.TeamPerformanceSplits(team_id)
    assert team.TeamLineups(team_id)
    assert team.TeamPlayers(team_id)
    assert team.TeamPlayerOnOffDetail(team_id)
    assert team.TeamPlayerOnOffSummary(team_id)
    assert team.TeamGameLogs(team_id)
    assert team.TeamShotTracking(team_id)
    assert team.TeamReboundTracking(team_id)
    assert team.TeamPassTracking(team_id)
    assert team.TeamVsPlayer(team_id, player_id)
Beispiel #2
0
def calculate_fantasy_points(player_id, opp_team_id):
    ftsy_prj = nba_team.TeamVsPlayer(opp_team_id, player_id, season='2017-18').vs_player_overall()
    ftsy_prj = ftsy_prj[0]['NBA_FANTASY_PTS'] if len(ftsy_prj) else 0

    ftsy_pts_last_5 = nba_player.PlayerLastNGamesSplits(player_id).last5()
    if not len(ftsy_pts_last_5):
        ftsy_pts_last_5 = 0
        ftsy_pts_last_10 = 0
    else:
        ftsy_pts_last_5 = ftsy_pts_last_5[0]['NBA_FANTASY_PTS']

        ftsy_pts_last_10 = nba_player.PlayerLastNGamesSplits(player_id).last10()
        ftsy_pts_last_10 = ftsy_pts_last_10[0]['NBA_FANTASY_PTS'] if len(ftsy_pts_last_10) else 0

    recent_form = 1 if (ftsy_pts_last_10 == 0 or ftsy_pts_last_5 == 0) else (ftsy_pts_last_5/ftsy_pts_last_10)

    recent_form = min(max(.85, recent_form), 1.15)
    ftsy_prj = round(ftsy_prj * recent_form, 1)
    value = ftsy_prj/ftsy_pts_last_10 if ftsy_pts_last_10 > 0 else 1
    return (ftsy_prj, value)
 def testAll(self):
     assert team.TeamList()
     assert team.TeamSummary(self.teamId)
     team_details = team.TeamDetails(self.teamId)
     assert team_details
     # assert team_details.background()
     # assert team_details.history()
     assert team.TeamCommonRoster(self.teamId)
     assert team.TeamGeneralSplits(self.teamId)
     assert team.TeamOpponentSplits(self.teamId)
     assert team.TeamLastNGamesSplits(self.teamId)
     assert team.TeamInGameSplits(self.teamId)
     assert team.TeamClutchSplits(self.teamId)
     assert team.TeamShootingSplits(self.teamId)
     assert team.TeamPerformanceSplits(self.teamId)
     assert team.TeamLineups(self.teamId)
     assert team.TeamPlayers(self.teamId)
     assert team.TeamPlayerOnOffDetail(self.teamId)
     assert team.TeamPlayerOnOffSummary(self.teamId)
     assert team.TeamGameLogs(self.teamId)
     assert team.TeamShotTracking(self.teamId)
     assert team.TeamReboundTracking(self.teamId)
     assert team.TeamPassTracking(self.teamId)
     assert team.TeamVsPlayer(self.teamId, self.playerId)
Beispiel #4
0
from nba_py import team
from nba_py.player import get_player
from nba_py.constants import *

# What this will do is get the stats for:
# Spurs vs Tyson Chandler for the 2010-11 season
plyr = get_player('Tyson', 'Chandler', just_id=False)
tvp = team.TeamVsPlayer(team_id=TEAMS['SAS']['id'],
                        vs_player_id=plyr['PERSON_ID'],
                        season='2010-11')
sa_on = tvp.shot_area_on_court()

try:
    r_on = (i for i in sa_on
            if i["GROUP_VALUE"] == "Restricted Area").__next__()
except AttributeError:
    r_on = next(i for i in sa_on if i["GROUP_VALUE"] == "Restricted Area")
# rest_on = sa_on[sa_on.GROUP_VALUE == 'Restricted Area']
sa_off = tvp.shot_area_off_court()
try:
    r_off = (i for i in sa_off
             if i["GROUP_VALUE"] == "Restricted Area").__next__()
except AttributeError:
    r_off = next(i for i in sa_off if i["GROUP_VALUE"] == "Restricted Area")
# rest_off = sa_off[sa_off.GROUP_VALUE == 'Restricted Area']
print('Spurs stats vs Tyson Chandler (2010-11)')
print('On court:  {}'.format(float(r_on['FG_PCT'])))
print('Off court: {}'.format(float(r_off['FG_PCT'])))
Beispiel #5
0
from sklearn import datasets
import pandas as pd
from nba_py import team

clips = team.TeamLineups(1610612746)

isBlakeGood = team.TeamVsPlayer(1610612746, 201933)

print(isBlakeGood.shot_distance_off_court().head(10),
      isBlakeGood.shot_distance_on_court().head(10))