nba_team_charts.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:nba_shot_charts 作者: Connor-R 项目源码 文件源码
def get_key_text(team_id, season_id, isCareer):

    text = ''

    games_text = get_metrics(team_id, season_id, isCareer, 'All', 'r.games')
    all_zone_plus = ("%.1f" % get_overall_zone_pct(team_id, season_id, isCareer))

    for _type in ('All', 'Above The Break 3', 'Corner 3', 'Mid-Range', 'In The Paint (Non-RA)', 'Restricted Area'):
        if _type == 'All':
            text += 'All Shots | %s Games | ' % games_text
        elif _type == 'Above The Break 3':
            text += '\n' + 'Arc 3 | '
        elif _type == 'In The Paint (Non-RA)':
            text += '\n' + 'Paint(Non-RA) | '
        elif _type == 'Restricted Area':
            text += '\n' + 'Restricted | '
        else:
            text += '\n' + _type + ' | '        

        atts = ("%.0f" %get_metrics(team_id, season_id, isCareer, _type, 'r.attempts'))
        makes = ("%.0f" %get_metrics(team_id, season_id, isCareer, _type, 'b.makes'))
        zone_pct = ("%.1f" % get_metrics(team_id, season_id, isCareer, _type, 'zone_pct*100'))
        zone_pct_plus = ("%.1f" % get_metrics(team_id, season_id, isCareer, _type, 'zone_pct_plus'))
        efg = ("%.1f" % get_metrics(team_id, season_id, isCareer, _type, 'efg*100'))
        efg_plus = ("%.1f" % get_metrics(team_id, season_id, isCareer, _type, 'efg_plus'))
        zone_efg_plus = ("%.1f" % get_metrics(team_id, season_id, isCareer, _type, 'zone_efg_plus'))
        paa = ("%.1f" % get_metrics(team_id, season_id, isCareer, _type, 'paa'))
        paa_game = ("%.1f" % get_metrics(team_id, season_id, isCareer, _type, 'paa_per_game'))

        if _type == 'All':
            text += str(makes) + ' for ' + str(atts)
            text += ' (' + str(all_zone_plus) + ' ShotSkill+ | '
            text += str(efg) + ' EFG% ('
            text += str(efg_plus) + ' EFG+ | '
            text += str(paa) + ' PAA)'
        else:
            text += str(makes) + '/' + str(atts) + ' | '
            text += str(zone_pct) + '% z% (' + str(zone_pct_plus) + ' z%+) | '
            text += str(zone_efg_plus) + ' zEFG+ ('
            text += str(efg_plus) + ' EFG+ | '
            text += str(paa) + ' PAA)'
    return text


#Getting the player's metrics for the given season
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号