Example #1
0
    def get_points(self):

        for index, playerrow in self.home_roster.iterrows():
            player_id = playerrow['PLAYER_ID']
            player_strength = playerrow['Strength']
            full_stats = player.PlayerSummary(player_id).headline_stats()
            current_season_stats = (full_stats[
                full_stats['TimeFrame'] == constants.CURRENT_SEASON]['PTS'])
            if len(current_season_stats) == 0:
                points = 0
            else:
                points = current_season_stats.tolist()[0] * player_strength

            self.home_roster.set_value(index, 'Points', points)

        for index, playerrow in self.away_roster.iterrows():
            player_id = playerrow['PLAYER_ID']
            player_strength = playerrow['Strength']
            full_stats = player.PlayerSummary(player_id).headline_stats()
            current_season_stats = (full_stats[
                full_stats['TimeFrame'] == constants.CURRENT_SEASON]['PTS'])
            if len(current_season_stats) == 0:
                points = 0
            else:
                points = current_season_stats.tolist()[0] * player_strength

            self.away_roster.set_value(index, 'Points', points)
Example #2
0
def get_player_attributes(all_teams_list):

    player_ids = []

    for team_abbr in all_teams_list:

        current_team = TEAMS[team_abbr]
        players_json = team.TeamPlayers(team_id=current_team['id']).json
        player_data_list = players_json['resultSets'][1]
        for player_data in player_data_list['rowSet']:

            player_id = player_data[1]
            player_ids.append(player_id)

    player_summary_list = []

    for player_id in player_ids:

        player_summary_json = player.PlayerSummary(player_id).json
        player_info = player_summary_json['resultSets'][0]

        player_headers = player_info['headers']
        player_stats = player_info['rowSet'][0]

        player_summary_dict = dict(zip(player_headers, player_stats))
        player_summary_list.append(player_summary_dict)

        print("Gathered data for {}".format(player_stats[3]))

    df = pd.DataFrame(player_summary_list)

    df = df[player_headers]

    df.to_excel('2016-17 NBA Player Attributes.xlsx')
Example #3
0
def players_and_season(playerid, season):
    # season example: "2016-17"
    # type example: "Regular Season" or "Playoffs"
    player_game_logs = player.PlayerGameLogs(playerid, season=season)
    player_games = player_game_logs.info()

    playoffs_playergamelogs = player.PlayerGameLogs(playerid,
                                                    season=season,
                                                    season_type="Playoffs")
    playoffs_player_games = playoffs_playergamelogs.info()

    player_summary = player.PlayerSummary(playerid)
    player_summary_info = player_summary.info()
    headline_stats = player_summary.headline_stats()

    birth_datestring = player_summary_info[0]["BIRTHDATE"][:10]
    birth_date = datetime.datetime.strptime(birth_datestring, "%Y-%m-%d")
    pretty_birth_date = birth_date.strftime("%m-%d-%Y")
    age = calculate_age(birth_date)

    player_headshot = "https://ak-static.cms.nba.com/wp-content/uploads/headshots/nba/latest/260x190/" + playerid + ".png"
    if (not test_link(player_headshot)):
        player_headshot = False

    return render_template("players.html",
                           title=player_summary_info[0]["DISPLAY_FIRST_LAST"],
                           player_games=player_games,
                           playoffs_player_games=playoffs_player_games,
                           player_summary_info=player_summary_info[0],
                           headline_stats=headline_stats[0],
                           age=age,
                           pretty_birth_date=pretty_birth_date,
                           season=season,
                           team_img=TEAM_ID_DATA,
                           player_headshot=player_headshot)
Example #4
0
 def get_points1(self, roster):
     player_pts = {}
     for index, playerrow in roster.iterrows():
         player_id = playerrow['PLAYER_ID']
         player_strength = playerrow['Strength']
         player_pts[player_id] = (player.PlayerSummary(
             player_id).headline_stats()['PTS'][0]) * player_strength
     return player_pts
def generate_player_summary_df(player_id_list):

    lst_of_dicts = []

    for id in player_id_list:
        print id
        player_summary = player.PlayerSummary(player_id=id).info()
        first_name = player_summary.FIRST_NAME.iloc[0]
        last_name = player_summary.LAST_NAME.iloc[0]
        display_name = player_summary.DISPLAY_FIRST_LAST.iloc[0]
        bday = player_summary.BIRTHDATE.iloc[0]
        bday = datetime.strptime(bday, '%Y-%m-%dT%H:%M:%S')
        age = (datetime.now() - bday).days
        ht = str(player_summary.HEIGHT.iloc[0])
        if ht:
            height_ft = int(ht.rsplit('-', 1)[0]) * 12
            if ht.rsplit('-', 1)[1]:
                height_in = int(ht.rsplit('-', 1)[1])
            else:
                height_in = 0
            height = height_ft + height_in
        else:
            height = 0
        wt = str(player_summary.WEIGHT.iloc[0])
        if wt:
            weight = int(wt)
        else:
            weight = 0
        seasons = player_summary.SEASON_EXP.iloc[0]
        position = player_summary.POSITION.iloc[0]
        roster_status = player_summary.ROSTERSTATUS.iloc[0]
        team_id = player_summary.TEAM_ID.iloc[0]
        team_name = player_summary.TEAM_NAME.iloc[0]
        d_league_flag = player_summary.DLEAGUE_FLAG.iloc[0]

        temp_dict = {
            'player_id': str(id),
            'first_name': first_name,
            'last_name': last_name,
            'display_name': display_name,
            'age': int(age),
            'height': height,
            'weight': weight,
            'season_exp': int(seasons),
            'position': position,
            'roster_status': roster_status,
            'team_id': str(team_id),
            'team_name': team_name,
            'dleague_flag': d_league_flag
        }

        lst_of_dicts.append(temp_dict)
        # time.sleep(1)

    player_summary_df = pd.DataFrame(lst_of_dicts)
    player_summary_df.set_index('player_id', inplace=True, drop=True)

    return player_summary_df
Example #6
0
 def sync_summary(self, player_id):
     summary = player.PlayerSummary(player_id).info()
     translation = self.player_translations.get(player_id, '')
     if translation:
         summary.loc[:, 'CHINESE_NAME'] = translation['CHINESE_NAME']
         summary.loc[:,
                     'CHINESE_POSITION'] = translation['CHINESE_POSITION']
         summary.loc[:, 'CHINESE_COUNTRY'] = translation['CHINESE_COUNTRY']
     summary.to_sql('player_summary', self.conn, if_exists='append')
Example #7
0
    def get_player_summary(self) -> pd.DataFrame:
        """Retrieve individual player summary data using API.
        """
        player_summary = pd.DataFrame()
        for player_data in self.player_list.itertuples(index=False):
            self.logger.info(f'Retrieving player summary data for {player_data.PERSON_ID}')

            if player_data.ROSTERSTATUS == 0:
                continue

            data = player.PlayerSummary(player_data.PERSON_ID).info()
            player_summary = player_summary.append(data, ignore_index=True)
            time.sleep(0.5)

        return player_summary
Example #8
0
def players(playerid):
    """Specific player pages.
    """
    player_summary = player.PlayerSummary(playerid)
    player_summary_info = player_summary.info()
    headline_stats = player_summary.headline_stats()

    to_year = int(player_summary_info[0]["TO_YEAR"])
    next_year = to_year + 1

    season = str(to_year) + "-" + str(next_year)[2:4]

    birth_datestring = player_summary_info[0]["BIRTHDATE"][:10]
    birth_date = datetime.datetime.strptime(birth_datestring, "%Y-%m-%d")
    pretty_birth_date = birth_date.strftime("%m-%d-%Y")
    age = calculate_age(birth_date)

    player_game_logs = player.PlayerGameLogs(playerid, season=season)
    player_games = player_game_logs.info()

    playoffs_playergamelogs = player.PlayerGameLogs(playerid,
                                                    season=season,
                                                    season_type="Playoffs")
    playoffs_player_games = playoffs_playergamelogs.info()

    player_career = player.PlayerCareer(playerid)
    player_career_regular_season_totals = player_career.regular_season_totals()
    player_career_post_season_totals = player_career.post_season_totals()

    player_headshot = "https://ak-static.cms.nba.com/wp-content/uploads/headshots/nba/latest/260x190/" + playerid + ".png"
    if (not test_link(player_headshot)):
        player_headshot = False

    return render_template(
        "players.html",
        title=player_summary_info[0]["DISPLAY_FIRST_LAST"],
        playerid=playerid,
        player_games=player_games,
        playoffs_player_games=playoffs_player_games,
        player_summary_info=player_summary_info[0],
        headline_stats=headline_stats[0],
        age=age,
        pretty_birth_date=pretty_birth_date,
        season=season,
        player_career_regular_season_totals=player_career_regular_season_totals,
        player_career_post_season_totals=player_career_post_season_totals,
        team_img=TEAM_ID_DATA,
        player_headshot=player_headshot)
Example #9
0
def load_all_player():
  header = ['PERSON_ID', 'FIRST_NAME', 'LAST_NAME', 'DISPLAY_FIRST_LAST',
            'BIRTHDATE', 'SCHOOL', 'COUNTRY', 'HEIGHT', 'WEIGHT',
            'POSITION', 'ROSTERSTATUS', 'TEAM_ID', 'FROM_YEAR',
            'TO_YEAR', 'DRAFT_YEAR', 'DRAFT_ROUND', 'DRAFT_NUMBER']
  resDF = pd.DataFrame()
  players = PlayerList().info()
  person_id_list = players['PERSON_ID']
  for id in person_id_list:
    print(id)
    player_info = player.PlayerSummary(id).info()
    player_info = player_info[header]
    resDF = resDF.append(player_info)
    time.sleep(1)
  resDF = resDF[resDF.TEAM_ID != 0]
  resDF.to_csv("data/player/players.csv", index=False)
Example #10
0
def test():
    pid = get_player('Tim', 'Duncan')
    vs_pid = get_player('Stephen', 'Curry')
    assert player.PlayerList()
    assert player.PlayerSummary(pid)
    # assert player.PlayerGeneralSplits(pid)
    # assert player.PlayerOpponentSplits(pid)
    assert player.PlayerLastNGamesSplits(pid)
    assert player.PlayerInGameSplits(pid)
    assert player.PlayerClutchSplits(pid)
    # assert player.PlayerShootingSplits(pid)
    assert player.PlayerPerformanceSplits(pid)
    assert player.PlayerYearOverYearSplits(pid)
    assert player.PlayerCareer(pid)
    assert player.PlayerProfile(pid)
    assert player.PlayerGameLogs(pid)
    assert player.PlayerShotTracking(pid)
    assert player.PlayerReboundTracking(pid)
    assert player.PlayerPassTracking(pid)
    assert player.PlayerDefenseTracking(pid)
    # assert player.PlayerShotLogTracking(pid)
    # assert player.PlayerReboundLogTracking(pid)
    assert player.PlayerVsPlayer(pid, vs_pid)
Example #11
0
    def testAll(self):
        assert player.PlayerList()
        assert player.PlayerSummary(self.playerId)
        # assert player.PlayerGeneralSplits(self.playerId)
        # assert player.PlayerOpponentSplits(self.playerId)
        assert player.PlayerLastNGamesSplits(self.playerId)
        assert player.PlayerInGameSplits(self.playerId)
        assert player.PlayerClutchSplits(self.playerId)
        # assert player.PlayerShootingSplits(self.playerId)
        assert player.PlayerPerformanceSplits(self.playerId)
        assert player.PlayerYearOverYearSplits(self.playerId)

        assert player.PlayerCareer(self.playerId)

        assert player.PlayerProfile(self.playerId)
        assert player.PlayerGameLogs(self.playerId)
        assert player.PlayerShotTracking(self.playerId)
        assert player.PlayerReboundTracking(self.playerId)
        assert player.PlayerPassTracking(self.playerId)
        assert player.PlayerDefenseTracking(self.playerId)
        # assert player.PlayerShotLogTracking(self.playerId)
        # assert player.PlayerReboundLogTracking(self.playerId)
        assert player.PlayerVsPlayer(self.playerId, self.vs_playerId)
Example #12
0
def players(request, first, last, player_id):
    playersummary = player.PlayerSummary(player_id)

    playersummary = playersummary.info()

    name = playersummary['DISPLAY_FIRST_LAST'][0]
    fname = playersummary['FIRST_NAME'][0]
    lname = playersummary['LAST_NAME'][0]
    birthdate = playersummary['BIRTHDATE'][0]
    school = playersummary['SCHOOL'][0]
    country = playersummary['COUNTRY'][0]
    player_id = playersummary['PERSON_ID'][0]

    context = {
        'name': name,
        'fname': fname,
        'lname': lname,
        'birthdate': birthdate,
        'school': school,
        'country': country,
        'player_id': player_id
    }

    return render(request, 'yearly/playerinfo.html', context)
Example #13
0
def nba():
    body = request.values['Body']
    nba_players = player.PlayerList(league_id='00',
                                    season='2018-19',
                                    only_current=1).info()
    pid = nba_players[nba_players.DISPLAY_FIRST_LAST == str(body)]['PERSON_ID']
    info = player.PlayerGameLogs(pid, season='2018-19').info()
    numbers = '\n' + '2018-19 Stats' + '\n' + 'PTS: ' + str(
        info.PTS.mean().round(1)) + '\n' + 'AST: ' + str(
            info.AST.mean().round(1)) + '\n' + 'REB: ' + str(
                info.REB.mean().round(1)) + '\n' + 'STL: ' + str(
                    info.REB.mean().round(1)) + '\n' + 'BLK: ' + str(
                        info.STL.mean().round(1))
    ps = player.PlayerSummary(pid)
    ps = ps.info()
    ps = ps.to_dict()
    psa = str(body) + '\n' + 'TEAM: ' + str(
        ps['TEAM_NAME'][0]) + '\n' + 'HEIGHT: ' + str(
            ps['HEIGHT'][0]) + '\n' + 'POSITION: ' + str(ps['POSITION'][0])
    fr = str(psa) + str(numbers)
    r = MessagingResponse()
    res = str(fr)
    r.message(res)
    return str(r)
Example #14
0
def print_player_information(first_name, last_name):
    print("What information about the player would you like to view?")
    print("1. Basic Info (Vitals)")
    print("2. View Season Averages")
    print("3. Compare to Another Player")
    print("9. Go back to main menu")
    choice = input("Pick a number from the list above.\n")

    # getting basic info
    if int(choice) == 1:
        first_name.strip()
        last_name.strip()
        id = player_functions.get_player_id(first_name, last_name) # the id of the player requested
        if id is None:
            print("The player was not found")
        else:
            # getting the basic player summary
            player_summary = player.PlayerSummary(id)
            vitals = player_summary.info()
            printer.pprint(vitals)
    # submenu for season averages
    elif int(choice) == 2:
        first_name.strip()
        last_name.strip()
        id = player_functions.get_player_id(first_name, last_name)  # the id of the player requested
        if id is None:
            print("The player was not found")
        else:
            print("1. View Headline Stats for this Season")
            print("2. View Regular Season Totals")
            print("3. View Career Regular Season Totals")
            print("4. View Post Season Totals")
            print("5. View Career Post Season Totals")
            print("6. View All Star Season Totals")
            print("7. View Career All Star Season Totals")
            print("8. View College Season Totals")
            print("9. View Career College Season Totals")
            player_career = player.PlayerCareer(id)
            choice = input("Pick a number from the list above.\n")
            num = int(choice)

            print()
            print()

            if num == 1:
                player_summary = player.PlayerSummary(id)
                printer.pprint(player_summary.headline_stats())
            elif num == 2:
                # view regular season totals
                printer.pprint(player_career.regular_season_totals())
            elif num == 3:
                printer.pprint(player_career.regular_season_career_totals())
            elif num == 4:
                printer.pprint(player_career.post_season_totals())
            elif num == 5:
                printer.pprint(player_career.post_season_career_totals())
            elif num == 6:
                printer.pprint(player_career.all_star_season_totals())
            elif num == 7:
                printer.pprint(player_career.career_all_star_season_totals())
            elif num == 8:
                printer.pprint(player_career.college_season_totals())
            elif num == 9:
                printer.pprint(player_career.college_season_career_totals())

            print()
            print()

    elif int(choice) == 3:
        vs_player_first_name = input("What is the first name of the player you'd like to compare against?\n")
        vs_player_last_name = input("What is their last name?\n")

        id = player_functions.get_player_id(first_name, last_name)
        vs_player_id = player_functions.get_player_id(vs_player_first_name, vs_player_last_name)  # the id of the player to be compared against
        printer.pprint(player.PlayerVsPlayer(id, vs_player_id, season='2017-18').overall())



    #tryna dip
    elif int(choice) == 9:
        return

    elif int(choice) == 100:
        printer.pprint(player.get_player(first_name, last_name, season='2017-18', just_id=False))
    else:
        print("Invalid menu choice")
Example #15
0
from nba_py import team
from nba_py import game
from nba_py import player
from nba_py.constants import *
import pandas as pd
import pprint

ap = player.PlayerSummary("977")
full_dict = {}
pprint.pprint(ap.headline_stats().to_dict())
print "*" * 40
pprint.pprint(ap.info().to_dict())
Example #16
0
import json
import sys
import webbrowser
import os
from nba_py import team as team
from nba_py import player as p
from nba_py import constants as constants

firstName = sys.argv[1]
lastName = sys.argv[2]

print(firstName + " " + lastName + " " + "Stats")
pID = (p.get_player(firstName, lastName))

shootingSplits = p.PlayerShootingSplits(pID).shot_areas()
playerInfo = p.PlayerSummary(pID).info()
headlineStats = p.PlayerSummary(pID).headline_stats()

playerPhotoLink = "http://ak-static.cms.nba.com/wp-content/uploads/headshots/nba/latest/260x190/" + str(
    pID) + ".png"
linkJSON = {}
print(json.dumps(headlineStats, indent=4))
print(type(playerInfo))
playerInfo[0]["link"] = playerPhotoLink

twoMade = 0
twoAttempted = 0

threeMade = 0
threeAttempted = 0
Example #17
0
from nba_py import team
from nba_py import game
from nba_py import player

# Third_quarter.py grabs all the information necessary from stats.nba.com
# using nba_py and saves it to .csv files.
# The actual analysis and all the visualizations are in the R files.

# get players stats for each quarter
warr = team.TeamCommonRoster(1610612744, season='2017-18')
players_ids = warr.roster()["PLAYER_ID"]
splits = []
players_summaries = [] 
for pid in players_ids:
    print("Erorre qui")
    players_summaries.append(player.PlayerSummary(pid).info())
    splits.append(player.PlayerInGameSplits(pid, season="2017-18", period="0"))
print("Errore qua")
first = True
for split in splits:
    if first:
        split.by_period().to_csv('players_splits.csv', mode='a', header=True)
        first = False
    else:
        split.by_period().to_csv('players_splits.csv', mode='a', header=False)
first = True
for summary in players_summaries:
    if first:
        summary.to_csv('players_summaries.csv', mode='a', header=True)
        first = False
    else:
Example #18
0
from __future__ import print_function
from nba_py import player

# endpoint currently disabled on stats.nba.com
# pd = player._PlayerDashboard('203507')
# print(pd.starting_position())

ap = player.PlayerList()
print(ap.info())

pc = player.PlayerSummary('203507')
print(pc.headline_stats())

p_cstats = player.PlayerCareer('201939')
print(p_cstats.regular_season_career_totals())
def get_player_info(player_id):
    summary = player.PlayerSummary(player_id)
    return summary
Example #20
0
def save_or_update_players():
    players = Player.objects.all()
    print("updating players stats")

    playerList = player.PlayerList()
    for val in playerList.info():

        playerApp = Player()
        playerApp.id_nba = val['PERSON_ID']
        try:
            playerApp = Player.objects.get(id_nba=playerApp.id_nba)

        except Player.DoesNotExist:
            playerApp.id_nba = val['PERSON_ID']
            player_summary = player.PlayerSummary(playerApp.id_nba)
            playerApp.name = player_summary.info().__getitem__(
                0)['DISPLAY_FIRST_LAST']
            playerApp.position = player_summary.info().__getitem__(
                0)['POSITION']
            playerApp.number = player_summary.info().__getitem__(0)['JERSEY']
            playerApp.height = player_summary.info().__getitem__(0)['HEIGHT']
            playerApp.weight = player_summary.info().__getitem__(0)['WEIGHT']
            birth_date = player_summary.info().__getitem__(0)['BIRTHDATE']

            playerApp.birth_date = birth_date[:10]
            playerApp.college = player_summary.info().__getitem__(0)['SCHOOL']
            playerApp.draft = player_summary.info().__getitem__(
                0)['DRAFT_YEAR']
            playerApp.experience = player_summary.info().__getitem__(
                0)['SEASON_EXP']
            try:
                teamApp = Team.objects.get(
                    name=player_summary.info().__getitem__(0)['TEAM_NAME'])
                playerApp.team = teamApp
            except Team.DoesNotExist:
                pass

        try:
            playerApp.save()
            player_general_splits = player.PlayerGeneralSplits(
                playerApp.id_nba)

            if player_general_splits.overall():
                statistic1 = PlayerStatistic()
                try:
                    statistic1 = PlayerStatistic.objects.get(player=playerApp)
                except PlayerStatistic.DoesNotExist:
                    statistic1.season = Season.objects.get(year="2017/18")
                    statistic1.player = playerApp
                    statistic1.playoff = False

                statistic1.ppg = player_general_splits.overall().__getitem__(
                    0)['PTS']
                statistic1.rpg = player_general_splits.overall().__getitem__(
                    0)['REB']
                statistic1.apg = player_general_splits.overall().__getitem__(
                    0)['AST']
                statistic1.bpg = player_general_splits.overall().__getitem__(
                    0)['BLK']
                statistic1.spg = player_general_splits.overall().__getitem__(
                    0)['STL']
                statistic1.tpg = player_general_splits.overall().__getitem__(
                    0)['TOV']
                statistic1.mpg = player_general_splits.overall().__getitem__(
                    0)['MIN']

                statistic1.ttp = player_general_splits.overall().__getitem__(
                    0)['FG3_PCT']
                statistic1.fgp = player_general_splits.overall().__getitem__(
                    0)['FG_PCT']
                statistic1.ftp = player_general_splits.overall().__getitem__(
                    0)['FT_PCT']

                statistic1.ftm = player_general_splits.overall().__getitem__(
                    0)['FTM']
                statistic1.fgm = player_general_splits.overall().__getitem__(
                    0)['FGM']
                statistic1.ttm = player_general_splits.overall().__getitem__(
                    0)['FG3M']

                statistic1.save()
                print("salvou ou atualizou jogador:" + playerApp.name)
        except ValueError:
            pass
Example #21
0
def get_long_player_bio(player_id):
    return LongPlayerBioNode(nba_py_player.PlayerSummary(player_id).info()[0])
Example #22
0
                           'weight'   : weight,
                           'positions' : positions,
                           'overview_url': overview_url,
                          })

	'''

    #print len(players.keys())

    try:
        get_player = player.get_player(firstname, last_name=lastname)
        #print get_player

        player_id = get_player.values[0]
        #print player_id
        player_summary = player.PlayerSummary(player_id)
        team_name = player_summary.info(
        )["TEAM_CITY"][0] + ' ' + player_summary.info()["TEAM_NAME"][0]

        print i, firstname, lastname + ':', team_name
        birthday = player_summary.info()["BIRTHDATE"][0].split('T')[0]
        from_year = player_summary.info()["FROM_YEAR"][0]
        jersey = player_summary.info()["JERSEY"][0]
        school = player_summary.info()["SCHOOL"][0]

        userRecord = collection.find_one({
            'lastname': lastname,
            'firstname': firstname
        })
        if userRecord:
Example #23
0
    def __init__(self,
                 playerId,
                 teamId,
                 paceAdjustment,
                 position=None,
                 salary=0,
                 freeAgent=False):
        self.playerId = playerId
        self.teamId = teamId
        self.paceAdjustment = paceAdjustment

        # Access stats from NBA Stats through nba_py module
        summary = player.PlayerSummary(playerId)
        info = summary.info()[0]
        header = player.PlayerSummary(playerId).headline_stats()[0]

        # Determine age in years from birthdate given in profile
        # NOTE: Age is current age today, not during this season
        bday = info['BIRTHDATE']
        date = datetime.date(int(bday[:4]), int(bday[5:7]), int(bday[8:10]))
        self.age = (datetime.date.today() - date).days / 365.0
        years = player.PlayerYearOverYearSplits(playerId).by_year()
        i = 0

        # find stats from the current season, if stats incomplete for that season return
        # an earlier season
        while (str(years[i]['GROUP_VALUE']) != constants.SEASON
               and (i < len(years) - 1)):
            i += 1
        if (i == len(years)):
            pc = years[len(years) - 1]
        else:
            pc = years[i]

        self.isFreeAgent = freeAgent
        self.name = str(header['PLAYER_NAME'])
        if (playerId in constants.HUSTLE.keys()):
            (sa, df, lbr, cd, cs) = constants.HUSTLE[playerId]
        else:
            (sa, df, lbr, cd, cs) = constants.HUSTLE_AVG
        self.sa = sa  # screen assists
        self.df = df  # deflections
        self.lbr = lbr  # loose balls recovered
        self.cd = cd  # charges drawn
        self.cs = cs  # contested shots
        self.tp = pc['FG3M'] * 1.0  # three points made
        self.mp = pc['MIN'] * 1.0  # minutes played
        self.ast = pc['AST'] * 1.0  # assists
        self.fg = pc['FGM'] * 1.0  # field goals
        self.tov = pc['TOV'] * 1.0  # turnovers
        self.fga = pc['FGA'] * 1.0  # field goals attempted
        self.fta = pc['FTA'] * 1.0  # free throws attempted
        self.ft = pc['FTM'] * 1.0  # free throws made
        self.stl = pc['STL'] * 1.0  # steals
        self.orb = pc['OREB'] * 1.0  # offensive rebounds
        self.blk = pc['BLK'] * 1.0  # blocks
        self.pf = pc['PF'] * 1.0  # personal fouls
        self.pts = pc['PTS'] * 1.0  # points
        self.trb = pc['REB'] * 1.0  # total rebounds
        self.drb = pc['DREB'] * 1.0  # defensive rebounds
        self.salary = salary  # cost of player
        if (position == None):
            self.position = str(info['POSITION'])  # position of player
        else:
            self.position = position
Example #24
0
def get_player_info(player_id):
    """Return player info."""
    player_info = player.PlayerSummary(player_id)
    return player_info.info()
def get_player_info(key):
    my_player = player.PlayerSummary(player_id)
    info = my_player.info()
    stat = info[key]
    return stat.item()