Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue generating weekly stats, due to records_df missing #116

Open
bdf0506 opened this issue Oct 15, 2024 · 1 comment
Open

Issue generating weekly stats, due to records_df missing #116

bdf0506 opened this issue Oct 15, 2024 · 1 comment

Comments

@bdf0506
Copy link

bdf0506 commented Oct 15, 2024

Discussions aren't enabled for this project, so apologies if this is not the right forum to ask for assistance.

I am trying to generate the weekly stats, but unable to. It complains about 'records_df' but I'm unsure what to do with this. I tried to reverse engineer a bit of the python coding but wasn't able to figure this out. Any guidance here for how to generate this? I'm able to get the library to do other things and pull other stats, but just not these weekly/season stats.

Python 3.12.7 (main, Oct  1 2024, 08:52:12) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from src.doritostats.fetch_utils import fetch_league
>>> league_id = 2004529243
>>> year = 2024
>>> league = fetch_league(league_id, year)
[BUILDING LEAGUE] Fetching league data...
[BUILDING LEAGUE] League endpoint set to: https://lm-api-reads.fantasy.espn.com/apis/v3/games/ffl/seasons/2024/segments/0/leagues/2004529243?
[BUILDING LEAGUE] Gathering roster settings information...
[BUILDING LEAGUE] Loading current league details...
>>> from src.doritostats.analytic_utils import weekly_stats_analysis
>>> weekly_stats_analysis(records_df, year=2024, week=3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'records_df' is not defined
>>> 
@DesiPilla
Copy link
Owner

@bdf0506 Sorry for not responding sooner. This error is because the weekly_stats_analysis() function expects a dataframe (records_df) that contains all the scraped matchup data. That can be pulled using the following code:

from src.doritostats.filter_utils import exclude_most_recent_week
from src.doritostats.scrape_team_stats import scrape_team_stats

min_year = 2019 # Or whatever the oldest year in your league was
max_year = 2024
records_df = scrape_team_stats(league_id, min_year, max_year, swid, espn_s2)
records_df = exclude_most_recent_week(records_df) # To remove the current week (since it's data is incomplete)
weekly_stats_analysis(records_df, year=2024, week=3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants