wsba_hockey.tools package

Submodules

wsba_hockey.tools.agg module

wsba_hockey.tools.agg.apply_params(df, group_by, params, stage='before')[source]
wsba_hockey.tools.agg.apply_rosters(df, group, schedule_path, roster_path)[source]
wsba_hockey.tools.agg.calc_goalie(pbp, game_strength, second_group)[source]
wsba_hockey.tools.agg.calc_indv(pbp, game_strength, second_group)[source]
wsba_hockey.tools.agg.calc_onice(pbp, game_strength, second_group)[source]
wsba_hockey.tools.agg.calc_team(pbp, game_strength, second_group)[source]
wsba_hockey.tools.agg.concat_col_values(s)[source]
wsba_hockey.tools.agg.extra_calc(df, metrics)[source]
wsba_hockey.tools.agg.process_stats(df, group, venue, game_strength, second_group)[source]
wsba_hockey.tools.agg.rank_stats(df, rates=True, comparison=True, group_by=None)[source]
wsba_hockey.tools.agg.sum_unique_games(series, games_df_ref, col_name)[source]

wsba_hockey.tools.globals module

wsba_hockey.tools.globals.convert_to_seconds(minutes)[source]
wsba_hockey.tools.globals.get_contents(game_html)[source]
wsba_hockey.tools.globals.get_soup(shifts_html)[source]
wsba_hockey.tools.globals.get_team(team)[source]
wsba_hockey.tools.globals.get_teams(soup)[source]

wsba_hockey.tools.http module

wsba_hockey.tools.http.get(url, **kwargs)[source]
wsba_hockey.tools.http.make_pooled_session() Session[source]
wsba_hockey.tools.http.pooled_session() Session[source]

wsba_hockey.tools.plotting module

class wsba_hockey.tools.plotting.WSBAPlot(display_range: str = 'full', rotation: int | None = 0, figsize=(10, 12), facecolor='w', edgecolor='k')[source]

Bases: object

flush()[source]
wsba_hockey.tools.plotting.apply_primary_colors(df: DataFrame, color_map: dict[str, str], *, team_abbr_col: str = 'event_team_abbr', season_col: str = 'season', out_col: str = 'color', fallback: str = '#1f77b4') DataFrame[source]
wsba_hockey.tools.plotting.load_teaminfo(info_path: str = '/home/runner/work/wsba_hockey/wsba_hockey/src/wsba_hockey/tools/teaminfo/nhl_teaminfo.csv') DataFrame[source]
wsba_hockey.tools.plotting.plot_events(pbp: DataFrame, events: list[str], title: str | None = None, marker_dict: dict | None = None, legend: bool = False, display_range: str = 'full', rotation: int | None = 0, figsize=(6.4, 4.8))[source]
wsba_hockey.tools.plotting.prep_plot_data(pbp, strengths, season_types=2, marker_dict={'blocked-shot': 'v', 'faceoff': 'X', 'giveaway': '1', 'goal': '*', 'hit': 'P', 'missed-shot': 'o', 'shot-on-goal': 'D', 'takeaway': '2'})[source]
wsba_hockey.tools.plotting.team_primary_color_map(teaminfo: DataFrame | None = None, *, info_path: str = '/home/runner/work/wsba_hockey/wsba_hockey/src/wsba_hockey/tools/teaminfo/nhl_teaminfo.csv') dict[str, str][source]
wsba_hockey.tools.plotting.wsba_rink(display_range: str = 'offense', rotation: int | None = 0, ax=None, figsize=(10, 12))[source]

wsba_hockey.tools.scraping module

wsba_hockey.tools.scraping.adjust_coords(pbp)[source]
wsba_hockey.tools.scraping.analyze_shifts(shift, id, name, pos, team)[source]
wsba_hockey.tools.scraping.apply_passing_imputation(pbp)[source]
wsba_hockey.tools.scraping.assign_target(data)[source]
wsba_hockey.tools.scraping.clean_html_pbp(info)[source]
wsba_hockey.tools.scraping.combine_data(info, sources)[source]
wsba_hockey.tools.scraping.combine_pbp(info, sources)[source]
wsba_hockey.tools.scraping.combine_shifts(info, sources)[source]
wsba_hockey.tools.scraping.edge_stat_entry(entry, season, season_type, type)[source]
wsba_hockey.tools.scraping.espn_game_id(date, away, home)[source]
wsba_hockey.tools.scraping.fix_players(pbp)[source]
wsba_hockey.tools.scraping.get_game_coaches(game_id)[source]
wsba_hockey.tools.scraping.get_game_info(game_id)[source]
wsba_hockey.tools.scraping.get_game_roster(json)[source]
wsba_hockey.tools.scraping.logical_sort(df)[source]
wsba_hockey.tools.scraping.parse_espn(date, away, home)[source]
wsba_hockey.tools.scraping.parse_game_roster(rost_df, game_id)[source]
wsba_hockey.tools.scraping.parse_html(info)[source]
wsba_hockey.tools.scraping.parse_json(info)[source]
wsba_hockey.tools.scraping.parse_shift_events(info, home)[source]
wsba_hockey.tools.scraping.parse_shifts_html(info, home)[source]
wsba_hockey.tools.scraping.parse_shifts_json(info)[source]
wsba_hockey.tools.scraping.strip_html_pbp(td, rosters)[source]

wsba_hockey.tools.xg_model module

wsba_hockey.tools.xg_model.nhl_apply_xG(pbp: DataFrame, states: bool = False) DataFrame[source]

Given play-by-play data, return this data with xG-related columns.

Parameters:
  • pbp (pd.DataFrame) – A DataFrame containing play-by-play data generated within the WBSA Hockey package.

  • states (bool, optional) – If True, recalculate score, Corsi, Fenwick, and penalty states before applying xG. Defaults to False, matching the previous xG module behavior.

Returns:

A DataFrame containing input play-by-play data with xG column.

Return type:

pd.DataFrame

Module contents