I'm a novice to python3, but a former developer. I've installed python3 on my MacBook Pro and I've accessed ESPN Fantasy Football database via Terminal. I'm using Visual Studio Code to run the following:
Successful:
Successful:
import pandas as pd import espnfantasyfootball as espn import espnsecrets league = espn.FantasyLeague(league_id=999999,year=2023,swid=espnsecrets.swid, espn_s2=espnsecrets.espn_s2)Error when running:
data = league.get_league_data()
Error:KeyError Traceback (most recent call last)
/Users/owner/Library/Mobile Documents/com~apple~CloudDocs/Documents/fantasyfootball.ipynb Cell 3 line 1
----> 1 mydata = league.get_league_data()
File /usr/local/lib/python3.11/site-packages/espnfantasyfootball/espnfantasyfootball.py:205, in FantasyLeague.get_league_data(self, week)
203 for week in weeks:
204 league_json = self.load_league(week)
--> 205 self.load_player_data(league_json, week)
206 self.load_team_names(week)
208 # After loading the data for the week, add a copy of the DataFrame to the list.
File /usr/local/lib/python3.11/site-packages/espnfantasyfootball/espnfantasyfootball.py:65, in FantasyLeague.load_player_data(self, league_json, week)
61 weeks = []
64 # Loop through each team
---> 65 for team in range(0, len(league_json['teams'])):
66
67 # Loop through each roster slot in each team
68 for slot in range(0, len(league_json['teams'][team]['roster']['entries'])):
69 # Append the week number to a list for each entry for each team
70 weeks.append(week)
KeyError: 'teams'
Any help would be greatly appreciated.
Larz60+ write Nov-21-2023, 10:16 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
I have added the tags for this post. Please use BBCode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
I have added the tags for this post. Please use BBCode tags on future posts.