Ice Hockey - uwaggs/usportspy GitHub Wiki

Ice Hockey Functions

The usportspy package includes functions to retrieve ice hockey-related data, such as schedules, team box scores, player box scores, and play-by-play data. Note that only women's ice hockey data is currently available in U SPORTS.

Functions

ice_hockey_get_schedule

Fetches the ice hockey schedule for the specified gender.

Parameters:

  • gender (str): Specifies the gender of the teams. Must be either "m" or "w".

Returns:

  • pd.DataFrame: A DataFrame containing the ice hockey schedule. The columns of the returned DataFrame are: date, away, away_score, home, home_score, status, notes, month, box_scores, conference, division, exhibition, postseason, and season.

Example:

from usportspy import ice_hockey_get_schedule

# Get the schedule for female teams
male_schedule = ice_hockey_get_schedule("w")
print(male_schedule.head())

Expected output:

      date        away  away_score          home  home_score status  ...                                         box_scores conference division  exhibition  postseason    season
0  Tue. 13     Moncton         0.0    St. Thomas         1.0  Final  ...  https://en.usports.ca/sports/wice/2023-24p/box...          0        0           0           1  2023-24p
1  Wed. 14   Dalhousie         0.0  Saint Mary's         2.0  Final  ...  https://en.usports.ca/sports/wice/2023-24p/box...          0        0           0           1  2023-24p
2  Fri. 16     Calgary         1.0  Saskatchewan         2.0  Final  ...  https://en.usports.ca/sports/wice/2023-24p/box...          0        0           0           1  2023-24p
3  Fri. 16    Manitoba         0.0   Mount Royal         6.0  Final  ...  https://en.usports.ca/sports/wice/2023-24p/box...          0        0           0           1  2023-24p
4  Fri. 16  St. Thomas         1.0       Moncton         0.0  Final  ...  https://en.usports.ca/sports/wice/2023-24p/box...          0        0           0           1  2023-24p

[5 rows x 14 columns]

ice_hockey_get_team_box_score

Fetches the team box score data for ice hockey teams over specified seasons. Only data for women's teams is available.

Parameters:

  • gender (str): Specifies the gender of the teams. Must be either "m" or "w".
  • seasons (list of int, optional): List of seasons (starting year) to filter by. If nothing is provided, data for all seasons will be returned.

Returns:

  • pd.DataFrame: A DataFrame containing the team box scores. The columns of the returned DataFrame are: team, goals_p1, goals_p2, goals_p3, goals_pot, goals_p2ot, goals_p3ot, goals_p4ot, goals_total, shots_1, shots_2, shots_3, shots_total, shots_ot, shots_2ot, shots_3ot, shots_4ot, game_id, season, and season_type.

Example:

from usportspy import ice_hockey_get_team_box_score

# Get team box scores for male teams for the 2019 and 2021 seasons (note: will return female data)
male_team_box_score = ice_hockey_get_team_box_score("m", [2019, 2021])
print(male_team_box_score.head())

Expected output:

     team  goals_p1  goals_p2  goals_p3  goals_pot  goals_p2ot  goals_p3ot  goals_p4ot  ...  shots_total  shots_ot  shots_2ot  shots_3ot  shots_4ot        game_id   season  season_type
0  Acadia         1       0.0       0.0        1.0         NaN         NaN         NaN  ...           20       1.0        NaN        NaN        NaN  20190917_7bxt  2019-20            r
1  Acadia         1       1.0       0.0        NaN         NaN         NaN         NaN  ...           35       NaN        NaN        NaN        NaN  20190927_x69c  2019-20            r
2  Acadia         0       3.0       3.0        NaN         NaN         NaN         NaN  ...           29       NaN        NaN        NaN        NaN  20190928_q2el  2019-20            r
3  Acadia         1       1.0       2.0        NaN         NaN         NaN         NaN  ...           35       NaN        NaN        NaN        NaN  20191011_94na  2019-20            r
4  Acadia         3       0.0       1.0        NaN         NaN         NaN         NaN  ...           30       NaN        NaN        NaN        NaN  20191016_5147  2019-20            r

[5 rows x 20 columns]

ice_hockey_get_player_box_score

Fetches the player box score data for ice hockey players over specified seasons. Only data for women's teams is available.

Parameters:

  • gender (str): Specifies the gender of the teams. Must be either "m" or "w".
  • seasons (list of int, optional): List of seasons (starting year) to filter by. If nothing is provided, data for all seasons will be returned.

Returns:

  • pd.DataFrame: A DataFrame containing the player box scores. The columns of the returned DataFrame are: skaters, player_number, pos, g, a, plus_minus, s, face_off_won, face_off_total, pim, team, ga, goalie_mins, sv, shots_against, goalie_pim, game_id, player_links, season, and season_type.

Example:

from usportspy import ice_hockey_get_player_box_score

# Get player box scores for male teams for the 2019 and 2021 seasons (note: will return female data)
male_player_box_score = ice_hockey_get_player_box_score("m", [2019, 2021])
print(male_player_box_score.head())

Expected output:

             skaters player_number  pos    g    a  plus_minus    s  ...  sv  shots_against  goalie_pim        game_id                                       player_links   season  season_type
0       Adam Holwell            13  NaN  0.0  1.0        -2.0  3.0  ... NaN            NaN         NaN  20200212_3fy5  /sports/mice/2019-20p/boxscores/20200212_3fy5....  2019-20            p
1      Adam Laishram            21  NaN  0.0  0.0        -1.0  1.0  ... NaN            NaN         NaN  20200212_3fy5  /sports/mice/2019-20p/boxscores/20200212_3fy5....  2019-20            p
2          Alex Noel            23  NaN  0.0  0.0        -1.0  4.0  ... NaN            NaN         NaN  20200212_3fy5  /sports/mice/2019-20p/boxscores/20200212_3fy5....  2019-20            p
3  Alexandre Bernier             9  NaN  0.0  0.0         0.0  2.0  ... NaN            NaN         NaN  20200212_3fy5  /sports/mice/2019-20p/boxscores/20200212_3fy5....  2019-20            p
4    Alexandre Jacob            26  NaN  0.0  0.0         0.0  3.0  ... NaN            NaN         NaN  20200212_3fy5  /sports/mice/2019-20p/boxscores/20200212_3fy5....  2019-20            p

[5 rows x 20 columns]

ice_hockey_get_pbp

Fetches the play-by-play (PBP) data for ice hockey games over specified seasons. Only data for women's teams is available.

Parameters:

  • gender (str): Specifies the gender of the teams. Must be either "m" or "w".
  • seasons (list of int, optional): List of seasons (starting year) to filter by. If nothing is provided, data for all seasons will be returned.

Returns:

  • pd.DataFrame: A DataFrame containing the play-by-play data. The columns of the returned DataFrame are: event, period, game_id, away_team, home_team, season, and season_type.

Example:

from usportspy import ice_hockey_get_pbp

# Get PBP data for female teams for the 2019 and 2021 seasons
female_pbp = ice_hockey_get_pbp("w", [2019, 2021])
print(female_pbp.head())

Expected output:

                                               event period        game_id away_team home_team   season season_type
0       [00:00] Audrey Berthiaume at goalie for UDM.      1  20200213_12zr  Moncton      UPEI   2019-20           p
1       [00:00] Camille Scherger at goalie for UPEI.      1  20200213_12zr  Moncton      UPEI   2019-20           p
2  Faceoff Katherine Dubuc vs Rachel Colle won by...      1  20200213_12zr  Moncton      UPEI   2019-20           p
3  [01:13] GOAL by UPEI Kelly Clements (FIRST GOA...      1  20200213_12zr  Moncton      UPEI   2019-20           p
4  Faceoff Janie Poitras vs Jolena Gillard won by...      1  20200213_12zr  Moncton      UPEI   2019-20           p
⚠️ **GitHub.com Fallback** ⚠️