Jon Solow commited on
Commit
b838c58
·
1 Parent(s): 973503c

Map some defensive players to be team defenses

Browse files
src/domain/playoffs.py CHANGED
@@ -54,18 +54,18 @@ PLAYOFFS_TEAMS = {
54
  }
55
 
56
  PLAYOFF_TEAM_DEF_PLAYER: list[tuple[teams.NFLTeam, str]] = [
57
- (teams.baltimore_ravens, ""),
58
- (teams.miami_dolphins, ""),
59
- (teams.kansas_city_chiefs, ""),
60
- (teams.houston_texans, ""),
61
- (teams.cleveland_browns, ""),
62
- (teams.san_francisco_49ers, ""),
63
- (teams.dallas_cowboys, ""),
64
- (teams.detroit_lions, ""),
65
- (teams.philadelphia_eagles, ""),
66
- (teams.los_angeles_rams, ""),
67
- (teams.tampa_bay_buccaneers, ""),
68
- (teams.buffalo_bills, ""),
69
- (teams.pittsburgh_steelers, ""),
70
- (teams.green_bay_packers, ""),
71
  ]
 
54
  }
55
 
56
  PLAYOFF_TEAM_DEF_PLAYER: list[tuple[teams.NFLTeam, str]] = [
57
+ (teams.baltimore_ravens, "00-0036323"),
58
+ (teams.miami_dolphins, "00-0033055"),
59
+ (teams.kansas_city_chiefs, "00-0032762"),
60
+ (teams.houston_texans, "00-0031298"),
61
+ (teams.cleveland_browns, "00-0033868"),
62
+ (teams.san_francisco_49ers, "00-0034815"),
63
+ (teams.dallas_cowboys, "00-0036932"),
64
+ (teams.detroit_lions, "00-0037236"),
65
+ (teams.philadelphia_eagles, "00-0027865"),
66
+ (teams.los_angeles_rams, "00-0031388"),
67
+ (teams.tampa_bay_buccaneers, "00-0034773"),
68
+ (teams.buffalo_bills, "00-0036888"),
69
+ (teams.pittsburgh_steelers, "00-0033886"),
70
+ (teams.green_bay_packers, "00-0034728"),
71
  ]
src/pages/10_Set_Your_Lineup.py CHANGED
@@ -7,7 +7,13 @@ from config import DEFAULT_ICON
7
  from shared_page import common_page_config
8
 
9
  from domain.constants import SEASON
10
- from domain.playoffs import PLAYOFF_WEEK_TO_NAME, CURRENT_PLAYOFF_WEEK, ROSTER_WEEK_TO_PLAYOFF_WEEK, PLAYOFFS_TEAMS
 
 
 
 
 
 
11
  from domain.teams import SCHEDULE_NAME_TO_PFR_NAME_MAP
12
  from queries.nflverse.github_data import get_weekly_rosters
13
  from queries.pfr.league_schedule import get_season_time_map
@@ -89,6 +95,13 @@ def player_options_from_df(df_options) -> dict[str, dict[int, list[PlayerOption]
89
  return options_map
90
 
91
 
 
 
 
 
 
 
 
92
  @st.cache_data(ttl=60 * 60 * 24)
93
  def load_options():
94
  df_rosters = get_weekly_rosters()
@@ -117,6 +130,7 @@ def load_options():
117
  df_rosters["in_playoffs"] = df_rosters.apply(lambda x: x.team in PLAYOFFS_TEAMS[x.week], axis=1)
118
 
119
  df_rosters = df_rosters[df_rosters.in_playoffs]
 
120
  player_options = player_options_from_df(df_rosters)
121
  return player_options
122
 
 
7
  from shared_page import common_page_config
8
 
9
  from domain.constants import SEASON
10
+ from domain.playoffs import (
11
+ PLAYOFF_WEEK_TO_NAME,
12
+ CURRENT_PLAYOFF_WEEK,
13
+ ROSTER_WEEK_TO_PLAYOFF_WEEK,
14
+ PLAYOFFS_TEAMS,
15
+ PLAYOFF_TEAM_DEF_PLAYER,
16
+ )
17
  from domain.teams import SCHEDULE_NAME_TO_PFR_NAME_MAP
18
  from queries.nflverse.github_data import get_weekly_rosters
19
  from queries.pfr.league_schedule import get_season_time_map
 
95
  return options_map
96
 
97
 
98
+ def modify_defensive_players_to_be_team_defense(df_options):
99
+ for team, player_id in PLAYOFF_TEAM_DEF_PLAYER:
100
+ if player_id in df_options.gsis_id.values:
101
+ df_options.loc[df_options.gsis_id == player_id, "position"] = "DEF"
102
+ df_options.loc[df_options.gsis_id == player_id, "full_name"] = team.team_name
103
+
104
+
105
  @st.cache_data(ttl=60 * 60 * 24)
106
  def load_options():
107
  df_rosters = get_weekly_rosters()
 
130
  df_rosters["in_playoffs"] = df_rosters.apply(lambda x: x.team in PLAYOFFS_TEAMS[x.week], axis=1)
131
 
132
  df_rosters = df_rosters[df_rosters.in_playoffs]
133
+ modify_defensive_players_to_be_team_defense(df_rosters)
134
  player_options = player_options_from_df(df_rosters)
135
  return player_options
136