For those who are familiar with MLB-StatsAPI in Python, I am looking for a way to find the previous five games a team has played. I have tried using statsai.schedule
, but it will not work for what I am trying to do.
CodePudding user response:
Try this -
import statsapi
sched = statsapi.schedule(start_date='07/01/2018',end_date='07/31/2018',team=143)
newlist = sorted(sched, key = lambda k: k["game_date"], reverse=True)
for game in newlist[0:5]:
print(game['game_date'] " : " str(game['game_id']))