我想创建一个逻辑条件,该条件根据敏锐的主队/客队得分的目标确定一支球队是赢还是输。
类似这样的事情: 对于game_id(),results.append赢得最多目标和结果的团队。appends损失其他团队的
results = []
for game_id in range(2017020001, 2017020010, 1):
url = 'https://statsapi.web.nhl.com/api/v1/game/{}/boxscore'.format(game_id)
r = requests.get(url)
game_data = r.json()
for homeaway in ['home','away']:
game_dict = game_data.get('teams').get(homeaway).get('teamStats').get('teamSkaterStats')
game_dict['team'] = game_data.get('teams').get(homeaway).get('team').get('name')
game_dict['homeaway'] = homeaway
game_dict['game_id'] = game_id
results.append(game_dict)
pd.DataFrame(results).set_index(['team','homeaway'])
想要一列['Win / Loss']来根据目标实现价值的赢或输