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.
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:league,season,game_id,date,exhibition,conference,playoffs,championship,home_team,away_team,home_score,away_score,game_link.
Example:
from usportspy import ice_hockey_get_schedule
# Get the schedule for female teams
female_schedule = ice_hockey_get_schedule("w")
print(female_schedule.head())
Expected output:
league season game_id date exhibition conference playoffs championship home_team away_team home_score away_score game_link
0 wice 2009-10 NaN 2009-09-18 True False False False york concordia 1 0 NaN
1 wice 2009-10 NaN 2009-09-20 True False False False brock carleton 0 5 NaN
2 wice 2009-10 NaN 2009-09-25 True False False False waynestate york 3 2 NaN
3 wice 2009-10 NaN 2009-09-26 True False False False york mississaugajrchiefs 2 2 NaN
4 wice 2009-10 NaN 2009-09-27 True False False False niagarau brock 5 2 NaN
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:team,jersey_number,player,position,goals,assists,plus_minus,shots,faceoffs_won,faceoffs_total,penalty_minutes,goals_allowed,minutes_played,saves,shots_against,starter_status,player_links,date,sport,link,game_id,season.
Example:
from usportspy import ice_hockey_get_player_box_score
# Get player box scores 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:
team jersey_number player position goals assists ... player_links date sport link game_id season
0 Moncton 4 Danick Crte d 0.0 1.0 ... NaN 2019-09-14 mice https://en.usports.ca/sports/mice/2019-20/boxs... 20190914_2h0g 2019-20
1 StFX 5 Michael Kemp d 0.0 0.0 ... NaN 2019-09-14 mice https://en.usports.ca/sports/mice/2019-20/boxs... 20190914_2h0g 2019-20
2 Moncton 7 Robbie Graham lw 1.0 0.0 ... NaN 2019-09-14 mice https://en.usports.ca/sports/mice/2019-20/boxs... 20190914_2h0g 2019-20
3 StFX 8 Olivier Desjardins NaN 0.0 0.0 ... NaN 2019-09-14 mice https://en.usports.ca/sports/mice/2019-20/boxs... 20190914_2h0g 2019-20
4 Moncton 9 Alexandre Bernier NaN 0.0 1.0 ... NaN 2019-09-14 mice https://en.usports.ca/sports/mice/2019-20/boxs... 20190914_2h0g 2019-20
[5 rows x 22 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:player,time,period,event,description,result,save,save_player,faceoff_player_one,faceoff_player_two,primary_assist,secondary_assist,event_two,shot_block_by,teams,penalty_reason,date,sport,link,game_id,season.
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:
player time period event ... sport link game_id season
0 Alexandra Lehmann 00:00 1st at goalie ... wice https://en.usports.ca/sports/wice/2019-20/boxs... 20190919_xeu9 2019-20
1 Kendra Woodland 00:00 1st at goalie ... wice https://en.usports.ca/sports/wice/2019-20/boxs... 20190919_xeu9 2019-20
2 NaN 00:00 1st faceoff ... wice https://en.usports.ca/sports/wice/2019-20/boxs... 20190919_xeu9 2019-20
3 Alayna Wagstaff 01:43 1st shot ... wice https://en.usports.ca/sports/wice/2019-20/boxs... 20190919_xeu9 2019-20
4 Megan Wilson 06:24 1st shot ... wice https://en.usports.ca/sports/wice/2019-20/boxs... 20190919_xeu9 2019-20
[5 rows x 21 columns]