Jon Solow
commited on
Commit
·
e6aafd7
1
Parent(s):
21e8914
Reduce repeated code in yahoo_stat obj
Browse files- src/stats.py +10 -9
src/stats.py
CHANGED
@@ -4,6 +4,7 @@ import pandas as pd
|
|
4 |
import requests
|
5 |
import streamlit as st
|
6 |
|
|
|
7 |
from domain.playoffs import PLAYOFF_TEAM_DEF_PLAYER
|
8 |
from login import get_stat_overrides
|
9 |
from queries.nflverse.github_data import get_player_kicking_stats, get_player_stats, get_team_defense_stats
|
@@ -251,7 +252,9 @@ def add_yahoo_stat_type_to_stat_map(
|
|
251 |
):
|
252 |
assert yahoo_stat_type in YAHOO_TO_STAT_MAP
|
253 |
|
254 |
-
|
|
|
|
|
255 |
week = YAHOO_WEEK_MAP[int(raw_week)]
|
256 |
if week not in stat_map:
|
257 |
stat_map[week] = {}
|
@@ -371,14 +374,12 @@ def get_yahoo_stats() -> dict[int, dict[str, dict[str, float]]]:
|
|
371 |
|
372 |
stats_json = dom_json["context"]["dispatcher"]["stores"]["GraphStatsStore"]
|
373 |
|
374 |
-
add_yahoo_stat_type_to_stat_map(stats_json["weeklyStatsFootballPassing"]
|
375 |
-
add_yahoo_stat_type_to_stat_map(stats_json["weeklyStatsFootballRushing"]
|
376 |
-
add_yahoo_stat_type_to_stat_map(
|
377 |
-
|
378 |
-
|
379 |
-
add_yahoo_stat_type_to_stat_map(stats_json["
|
380 |
-
return_stats = stats_json["weeklyStatsFootballReturns"]["nfl"]["200"]["2023"]
|
381 |
-
add_yahoo_stat_type_to_stat_map(stats_json["weeklyStatsFootballDefense"]["nfl"]["200"]["2023"], "DEFENSE", stat_map)
|
382 |
|
383 |
return stat_map
|
384 |
|
|
|
4 |
import requests
|
5 |
import streamlit as st
|
6 |
|
7 |
+
from domain.constants import SEASON
|
8 |
from domain.playoffs import PLAYOFF_TEAM_DEF_PLAYER
|
9 |
from login import get_stat_overrides
|
10 |
from queries.nflverse.github_data import get_player_kicking_stats, get_player_stats, get_team_defense_stats
|
|
|
252 |
):
|
253 |
assert yahoo_stat_type in YAHOO_TO_STAT_MAP
|
254 |
|
255 |
+
nfl_object = stats_object["nfl"]["200"][f"{SEASON}"]
|
256 |
+
|
257 |
+
for raw_week, week_dict in nfl_object.items():
|
258 |
week = YAHOO_WEEK_MAP[int(raw_week)]
|
259 |
if week not in stat_map:
|
260 |
stat_map[week] = {}
|
|
|
374 |
|
375 |
stats_json = dom_json["context"]["dispatcher"]["stores"]["GraphStatsStore"]
|
376 |
|
377 |
+
add_yahoo_stat_type_to_stat_map(stats_json["weeklyStatsFootballPassing"], "PASSING", stat_map)
|
378 |
+
add_yahoo_stat_type_to_stat_map(stats_json["weeklyStatsFootballRushing"], "RUSHING", stat_map)
|
379 |
+
add_yahoo_stat_type_to_stat_map(stats_json["weeklyStatsFootballReceiving"], "RECEIVING", stat_map)
|
380 |
+
add_yahoo_stat_type_to_stat_map(stats_json["weeklyStatsFootballKicking"], "KICKING", stat_map)
|
381 |
+
# return_stats = stats_json["weeklyStatsFootballReturns"]
|
382 |
+
add_yahoo_stat_type_to_stat_map(stats_json["weeklyStatsFootballDefense"], "DEFENSE", stat_map)
|
|
|
|
|
383 |
|
384 |
return stat_map
|
385 |
|