Jon Solow
commited on
Commit
·
62740e0
1
Parent(s):
d2c841f
Map to playoff week in the league schedule
Browse files
src/queries/pfr/league_schedule.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
import pandas as pd
|
2 |
|
|
|
|
|
3 |
|
4 |
def get_full_schedule(season_int: str | int) -> pd.DataFrame:
|
5 |
url = f"https://www.pro-football-reference.com/years/{season_int}/games.htm#games"
|
@@ -11,13 +13,12 @@ def get_full_schedule(season_int: str | int) -> pd.DataFrame:
|
|
11 |
|
12 |
|
13 |
def get_week_team_time_map(df_schedule: pd.DataFrame) -> dict[int, dict[str, pd.Timestamp]]:
|
14 |
-
|
15 |
-
max_week = 23
|
16 |
-
week_team_time_map: dict[int, dict[str, pd.Timestamp]] = {k: {} for k in range(min_week, max_week + 1)}
|
17 |
for _, row in df_schedule.iterrows():
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
21 |
return week_team_time_map
|
22 |
|
23 |
|
|
|
1 |
import pandas as pd
|
2 |
|
3 |
+
from domain.playoffs import SCHEDULE_WEEK_TO_PLAYOFF_WEEK
|
4 |
+
|
5 |
|
6 |
def get_full_schedule(season_int: str | int) -> pd.DataFrame:
|
7 |
url = f"https://www.pro-football-reference.com/years/{season_int}/games.htm#games"
|
|
|
13 |
|
14 |
|
15 |
def get_week_team_time_map(df_schedule: pd.DataFrame) -> dict[int, dict[str, pd.Timestamp]]:
|
16 |
+
week_team_time_map: dict[int, dict[str, pd.Timestamp]] = {k: {} for k in SCHEDULE_WEEK_TO_PLAYOFF_WEEK.values()}
|
|
|
|
|
17 |
for _, row in df_schedule.iterrows():
|
18 |
+
if mapped_week := SCHEDULE_WEEK_TO_PLAYOFF_WEEK.get(row.Week):
|
19 |
+
game_time = pd.to_datetime(row.Date + " " + row.Time, yearfirst=True)
|
20 |
+
week_team_time_map[mapped_week][row["Winner/tie"]] = game_time
|
21 |
+
week_team_time_map[mapped_week][row["Loser/tie"]] = game_time
|
22 |
return week_team_time_map
|
23 |
|
24 |
|