【发布时间】:2020-11-04 16:03:49
【问题描述】:
我正在使用sportsreference API 获取一些数据,但我不确定我做错了什么或者API 有问题。当我使用 API 提取我需要的数据时,它总是说客队获胜,即使在比赛中也不是这样。
代码sn-p:
from sportsreference.nba.boxscore import Boxscores
from sportsreference.nba.boxscore import Boxscore
# Select range of dates to get boxscores from (year, month, day)
games = Boxscores(datetime(2017, 10, 17), datetime(2017, 10, 20))
# Get boxscore abbreviations to get more detailed game boxscores
boxscore_abvs = []
for key in games.games.keys():
for i in range(len(games.games[key])):
boxscore_abvs.append(games.games[key][i]['boxscore'])
# Get more detailed boxscores
df = pd.DataFrame()
for abv in boxscore_abvs:
game_data = Boxscore(abv)
temp_df = game_data.dataframe
df = df.append(temp_df)
来自 df 的错误输出示例(骑士队赢得了这场比赛,API 报告凯尔特人队):
away_assist_percentage away_assists away_block_percentage away_blocks away_defensive_rating ... losing_name pace winner winning_abbr winning_name
201710170CLE 66.7 24 6.6 4 102.7 ... Cleveland Cavaliers 99.3 Away BOS Boston Celtics
【问题讨论】:
标签: python python-3.x dataframe