custom_charts.py 文件源码

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

项目:nba_shot_charts 作者: Connor-R 项目源码 文件源码
def get_key_text(_type, ids, start_date, end_date, metrics):

    text = ''

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

        atts = ("%.0f" % get_metrics(metrics, zone, 'attempts'))
        makes = ("%.0f" % get_metrics(metrics, zone, 'makes'))
        zone_pct = ("%.1f" % (float(100)*get_metrics(metrics, zone, 'z_pct')))
        zone_pct_plus = ("%.1f" % get_metrics(metrics, zone, 'zone_pct_plus'))
        efg = ("%.1f" % (float(100)*get_metrics(metrics, zone, 'efg')))
        efg_plus = ("%.1f" % get_metrics(metrics, zone, 'efg_plus'))
        zone_efg_plus = ("%.1f" % get_metrics(metrics, zone, 'ZONE_efg_plus'))
        paa = ("%.1f" % get_metrics(metrics, zone, 'paa'))
        paa_game = ("%.1f" % get_metrics(metrics, zone, 'paa_per_game'))

        if zone == 'All':
            text += str(makes) + ' for ' + str(atts) + ' | '
            text += str(efg) + ' EFG% ('
            text += str(efg_plus) + ' EFG+ | '
            text += str(paa) + ' PAA) | '
            text += str(paa_game) + ' PAA/G'
        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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号