Skip to main content

Library for easy querying of advanced NHL statistics.

Project description

pyhockey

Tool for querying advanced NHL data provided by MoneyPuck.com and NaturalStatTrick.com

API documentation available here.

Overview

A straightforward library that uses DuckDB and Polars to query a seperately-maintained database of NHL data scraped from MoneyPuck (https://www.moneypuck.com) and NaturalStatTrick (https://www.naturalstattrick.com).

Allows for easy access to season-summary data at the player- or team-level, as well as game-by-game data for each team. Game-by-game data is also available for players, but as of October 2025, this is only available for the 2025/2026 NHL season.

Examples

Season Summaries

To get the stats for each skater (i.e. non-goalies) on a team in a specific season with a minimum 1000 minutes of icetime:

>>> import pyhockey
>>> pyhockey.skater_seasons(team='TOR', season=2024, min_icetime=1000)
shape: (14, 21)
┌──────────┬────────┬──────────────────────┬──────┬──────────┬───────────┬─────────────┬─────────┬────────┬───────┬───────────┬──────────┬───────────────┬──────────────┬─────────────────┬─────────────────────┬──────────────────┬──────────────────────┬───────────────┬──────────────┬────────────────┐
 playerID  season  name                  team  position  situation  gamesPlayed  iceTime  points  goals  xGoalsFor  goalsFor  xGoalsAgainst  goalsAgainst  goalsForPerHour  goalsAgainstPerHour  xGoalsForPerHour  xGoalsAgainstPerHour  pointsPerHour  goalsPerHour  averageIceTime 
 ---       ---     ---                   ---   ---       ---        ---          ---      ---     ---    ---        ---       ---            ---           ---              ---                  ---               ---                   ---            ---           ---            
 i64       i64     str                   str   str       str        i64          f64      f64     f64    f64        f64       f64            f64           f64              f64                  f64               f64                   f64            f64           f64            
╞══════════╪════════╪══════════════════════╪══════╪══════════╪═══════════╪═════════════╪═════════╪════════╪═══════╪═══════════╪══════════╪═══════════════╪══════════════╪═════════════════╪═════════════════════╪══════════════════╪══════════════════════╪═══════════════╪══════════════╪════════════════╡
 8476931   2024    Jake McCabe           TOR   D         all        66           1419.83  23.0    2.0    64.72      76.0      74.66          75.0          3.21             3.17                 2.73              3.16                  0.97           0.08          21.51          
 8476872   2024    Scott Laughton        TOR   C         all        80           1168.03  31.0    13.0   47.29      42.0      59.62          76.0          2.16             3.9                  2.43              3.06                  1.59           0.67          14.6           
 8479318   2024    Auston Matthews       TOR   C         all        67           1371.63  78.0    33.0   101.7      105.0     82.36          78.0          4.59             3.41                 4.45              3.6                   3.41           1.44          20.47          
 8475690   2024    Chris Tanev           TOR   D         all        75           1481.2   18.0    3.0    64.67      72.0      71.17          64.0          2.92             2.59                 2.62              2.88                  0.73           0.12          19.75          
 8482720   2024    Matthew Knies         TOR   L         all        78           1444.17  58.0    29.0   91.62      103.0     77.97          74.0          4.28             3.07                 3.81              3.24                  2.41           1.2           18.51          
                                                                                                                                                                                                                                                                
 8478443   2024    Brandon Carlo         TOR   D         all        83           1568.7   12.0    1.0    59.18      59.0      85.97          90.0          2.26             3.44                 2.26              3.29                  0.46           0.04          18.9           
 8477939   2024    William Nylander      TOR   R         all        82           1599.78  84.0    45.0   109.83     122.0     83.84          67.0          4.58             2.51                 4.12              3.14                  3.15           1.69          19.51          
 8475171   2024    Oliver Ekman-Larsson  TOR   D         all        77           1622.28  29.0    4.0    82.82      86.0      71.64          70.0          3.18             2.59                 3.06              2.65                  1.07           0.15          21.07          
 8481122   2024    Simon Benoit          TOR   D         all        78           1290.62  10.0    1.0    42.76      48.0      72.78          58.0          2.23             2.7                  1.99              3.38                  0.46           0.05          16.55          
 8477503   2024    Max Domi              TOR   C         all        74           1048.67  33.0    8.0    48.57      53.0      43.75          39.0          3.03             2.23                 2.78              2.5                   1.89           0.46          14.17          
└──────────┴────────┴──────────────────────┴──────┴──────────┴───────────┴─────────────┴─────────┴────────┴───────┴───────────┴──────────┴───────────────┴──────────────┴─────────────────┴─────────────────────┴──────────────────┴──────────────────────┴───────────────┴──────────────┴────────────────┘

Can pass multiple values for team or season, as well as specify the situation ('5on5', '4on5', or '5on4'):

>>> import pyhockey
>>> pyhockey.skater_seasons(team=['TOR', 'MTL'], season=[2023, 2024], situation='5on5', min_icetime=1000)
shape: (35, 21)
┌──────────┬────────┬──────────────────────┬──────┬──────────┬───────────┬─────────────┬─────────┬────────┬───────┬───────────┬──────────┬───────────────┬──────────────┬─────────────────┬─────────────────────┬──────────────────┬──────────────────────┬───────────────┬──────────────┬────────────────┐
 playerID  season  name                  team  position  situation  gamesPlayed  iceTime  points  goals  xGoalsFor  goalsFor  xGoalsAgainst  goalsAgainst  goalsForPerHour  goalsAgainstPerHour  xGoalsForPerHour  xGoalsAgainstPerHour  pointsPerHour  goalsPerHour  averageIceTime 
 ---       ---     ---                   ---   ---       ---        ---          ---      ---     ---    ---        ---       ---            ---           ---              ---                  ---               ---                   ---            ---           ---            
 i64       i64     str                   str   str       str        i64          f64      f64     f64    f64        f64       f64            f64           f64              f64                  f64               f64                   f64            f64           f64            
╞══════════╪════════╪══════════════════════╪══════╪══════════╪═══════════╪═════════════╪═════════╪════════╪═══════╪═══════════╪══════════╪═══════════════╪══════════════╪═════════════════╪═════════════════════╪══════════════════╪══════════════════════╪═══════════════╪══════════════╪════════════════╡
 8481540   2023    Cole Caufield         MTL   R         5on5       82           1239.5   38.0    16.0   50.03      58.0      53.99          44.0          2.81             2.13                 2.42              2.61                  1.84           0.77          15.12          
 8476875   2023    Mike Matheson         MTL   D         5on5       82           1472.85  21.0    4.0    53.18      49.0      64.35          60.0          2.0              2.44                 2.17              2.62                  0.86           0.16          17.96          
 8483515   2023    Juraj Slafkovsky      MTL   L         5on5       82           1192.77  33.0    13.0   51.15      53.0      53.25          53.0          2.67             2.67                 2.57              2.68                  1.66           0.65          14.55          
 8482087   2023    Kaiden Guhle          MTL   D         5on5       70           1253.7   19.0    4.0    43.84      48.0      51.59          59.0          2.3              2.82                 2.1               2.47                  0.91           0.19          17.91          
 8478133   2023    Jake Evans            MTL   C         5on5       82           1015.2   22.0    5.0    37.41      34.0      44.4           42.0          2.01             2.48                 2.21              2.62                  1.3            0.3           12.38          
                                                                                                                                                                                                                                                                
 8478443   2024    Brandon Carlo         TOR   D         5on5       83           1323.27  11.0    1.0    49.1       46.0      52.38          50.0          2.09             2.27                 2.23              2.38                  0.5            0.05          15.94          
 8477939   2024    William Nylander      TOR   R         5on5       82           1241.83  42.0    24.0   54.43      61.0      52.17          41.0          2.95             1.98                 2.63              2.52                  2.03           1.16          15.14          
 8475171   2024    Oliver Ekman-Larsson  TOR   D         5on5       77           1370.22  24.0    2.0    54.29      60.0      54.14          51.0          2.63             2.23                 2.38              2.37                  1.05           0.09          17.8           
 8481122   2024    Simon Benoit          TOR   D         5on5       78           1110.95  9.0     1.0    36.31      44.0      48.4           34.0          2.38             1.84                 1.96              2.61                  0.49           0.05          14.24          
 8476931   2024    Jake McCabe           TOR   D         5on5       66           1173.87  21.0    2.0    46.64      59.0      41.37          41.0          3.02             2.1                  2.38              2.11                  1.07           0.1           17.79          
└──────────┴────────┴──────────────────────┴──────┴──────────┴───────────┴─────────────┴─────────┴────────┴───────┴───────────┴──────────┴───────────────┴──────────────┴─────────────────┴─────────────────────┴──────────────────┴──────────────────────┴───────────────┴──────────────┴────────────────┘

When querying multiple seasons, can set combine_seasons=True to combine stats for all seasons into a single row:

>>> import pyhockey
>>> pyhockey.skater_seasons(team='TOR', season=[2022, 2023, 2024], situation='5on5', min_icetime=1000, combine_seasons=True)
shape: (21, 21)
┌──────────┬────────────────┬──────────────────────┬──────┬──────────┬───────────┬─────────────┬─────────┬────────┬───────┬───────────┬──────────┬───────────────┬──────────────┬─────────────────┬─────────────────────┬──────────────────┬──────────────────────┬───────────────┬──────────────┬────────────────┐ 
 playerID  season          name                  team  position  situation  gamesPlayed  iceTime  points  goals  xGoalsFor  goalsFor  xGoalsAgainst  goalsAgainst  goalsForPerHour  goalsAgainstPerHour  xGoalsForPerHour  xGoalsAgainstPerHour  pointsPerHour  goalsPerHour  averageIceTime  
 ---       ---             ---                   ---   ---       ---        ---          ---      ---     ---    ---        ---       ---            ---           ---              ---                  ---               ---                   ---            ---           ---             
 i64       str             str                   str   str       str        i16          f64      i16     i16    f64        i16       f64            i16           f64              f64                  f64               f64                   f64            f64           f64             
╞══════════╪════════════════╪══════════════════════╪══════╪══════════╪═══════════╪═════════════╪═════════╪════════╪═══════╪═══════════╪══════════╪═══════════════╪══════════════╪═════════════════╪═════════════════════╪══════════════════╪══════════════════════╪═══════════════╪══════════════╪════════════════╡ 
 8470966   2022            Mark Giordano         TOR   D         5on5       78           1215.2   21      2      62.49      56        47.55          39            2.76             1.93                 3.09              2.35                  1.04           0.1           15.58           
 8474568   2022            Luke Schenn           TOR   D         5on5       70           1015.93  20      4      40.18      49        47.92          47            2.89             2.78                 2.37              2.83                  1.18           0.24          14.51           
 8474673   2022,2023       TJ Brodie             TOR   D         5on5       136          2460.82  34      2      108.41     114       98.62          102           2.78             2.49                 2.64              2.4                   0.83           0.05          18.09           
 8475166   2022,2023,2024  John Tavares          TOR   C         5on5       235          3278.6   113     51     151.32     157       133.9          123           2.87             2.25                 2.77              2.45                  2.07           0.93          13.95           
 8475171   2024            Oliver Ekman-Larsson  TOR   D         5on5       77           1370.22  24      2      54.29      60        54.14          51            2.63             2.23                 2.38              2.37                  1.05           0.09          17.8            
                                                                                                                                                                                                                                                                         
 8480043   2022            Timothy Liljegren     TOR   D         5on5       67           1035.42  13      5      52.53      50        41.75          31            2.9              1.8                  3.04              2.42                  0.75           0.29          15.45           
 8480144   2022            David Kampf           TOR   C         5on5       82           1007.92  23      7      40.85      37        40.28          38            2.2              2.26                 2.43              2.4                   1.37           0.42          12.29           
 8480950   2023            Ilya Lyubushkin       TOR   D         5on5       74           1029.3   8       0      37.94      37        46.46          50            2.16             2.91                 2.21              2.71                  0.47           0.0           13.91           
 8481122   2024            Simon Benoit          TOR   D         5on5       78           1110.95  9       1      36.31      44        48.4           34            2.38             1.84                 1.96              2.61                  0.49           0.05          14.24           
 8482720   2023,2024       Matthew Knies         TOR   L         5on5       158          2103.37  68      37     94.97      108       83.82          84            3.08             2.4                  2.71              2.39                  1.94           1.06          13.31           
└──────────┴────────────────┴──────────────────────┴──────┴──────────┴───────────┴─────────────┴─────────┴────────┴───────┴───────────┴──────────┴───────────────┴──────────────┴─────────────────┴─────────────────────┴──────────────────┴──────────────────────┴───────────────┴──────────────┴────────────────┘ 

The goalie_seasons() and team_seasons() functions work in the same way:

# goalie_seasons() uses min_games_played instead of min_icetime
>>> import pyhockey
>>> pyhockey.goalie_seasons(team=['TOR', 'MTL'], season=[2023, 2024], min_games_played=10)
shape: (10, 18)
┌──────────┬────────┬──────────────────┬──────┬───────────┬─────────────┬─────────┬────────┬───────┬────────────────┬───────────────────┬─────────────────┬─────────────────┬────────────────────┬──────────────────┬────────────────┬───────────────────┬─────────────────┐        
 playerID  season  name              team  situation  gamesPlayed  iceTime  xGoals  goals  lowDangerShots  mediumDangerShots  highDangerShots  lowDangerxGoals  mediumDangerxGoals  highDangerxGoals  lowDangerGoals  mediumDangerGoals  highDangerGoals         
 ---       ---     ---               ---   ---        ---          ---      ---     ---    ---             ---                ---              ---              ---                 ---               ---             ---                ---                     
 i64       i64     str               str   str        i64          f64      f64     f64    f64             f64                f64              f64              f64                 f64               f64             f64                f64                     
╞══════════╪════════╪══════════════════╪══════╪═══════════╪═════════════╪═════════╪════════╪═══════╪════════════════╪═══════════════════╪═════════════════╪═════════════════╪════════════════════╪══════════════════╪════════════════╪═══════════════════╪═════════════════╡        
 8478470   2023    Sam Montembeault  MTL   all        41           2428.77  130.34  127.0  1432.0          313.0              151.0            40.5             39.47               50.37             46.0            49.0               32.0                    
 8480051   2023    Cayden Primeau    MTL   all        23           1324.83  69.58   66.0   799.0           182.0              70.0             22.73            23.23               23.62             26.0            25.0               15.0                    
 8480051   2024    Cayden Primeau    MTL   all        11           523.7    31.53   41.0   267.0           88.0               37.0             9.05             10.95               11.52             22.0            14.0               5.0                     
 8482487   2024    Jakub Dobes       MTL   all        16           874.78   49.03   40.0   481.0           141.0              51.0             14.42            18.03               16.58             14.0            20.0               6.0                     
 8478470   2024    Sam Montembeault  MTL   all        62           3533.98  190.59  166.0  1864.0          497.0              224.0            54.67            62.12               73.8              61.0            66.0               39.0                    
 8478492   2023    Ilya Samsonov     TOR   all        40           2300.97  111.86  120.0  1251.0          272.0              136.0            34.27            32.97               44.63             44.0            41.0               35.0                    
 8474889   2023    Martin Jones      TOR   all        22           1169.67  62.3    56.0   632.0           153.0              72.0             19.05            19.42               23.84             21.0            21.0               14.0                    
 8479361   2023    Joseph Woll       TOR   all        25           1471.65  79.17   72.0   786.0           212.0              96.0             22.72            25.96               30.49             30.0            23.0               19.0                    
 8479361   2024    Joseph Woll       TOR   all        42           2442.33  127.85  111.0  1354.0          333.0              145.0            38.31            40.97               48.57             45.0            42.0               24.0                    
 8476932   2024    Anthony Stolarz   TOR   all        34           1986.9   96.78   71.0   1142.0          248.0              111.0            30.41            31.81               34.58             24.0            27.0               20.0                    
└──────────┴────────┴──────────────────┴──────┴───────────┴─────────────┴─────────┴────────┴───────┴────────────────┴───────────────────┴─────────────────┴─────────────────┴────────────────────┴──────────────────┴────────────────┴───────────────────┴─────────────────┘        
>>> import pyhockey
>>> pyhockey.team_seasons(season=list(range(2019, 2025)), combine_seasons=True)
shape: (33, 14)
┌───────────────────────────────┬──────┬───────────┬─────────────┬──────────┬─────────────┬──────────┬───────────────┬──────────────┬─────────────────┬─────────────────────┬──────────────────┬──────────────────────┬────────────────┐
 season                         team  situation  gamesPlayed  iceTime   xGoalsFor    goalsFor  xGoalsAgainst  goalsAgainst  goalsForPerHour  goalsAgainstPerHour  xGoalsForPerHour  xGoalsAgainstPerHour  averageIceTime 
 ---                            ---   ---        ---          ---       ---          ---       ---            ---           ---              ---                  ---               ---                   ---            
 str                            str   str        i16          f64       f32          i16       f32            i16           f64              f64                  f64               f64                   f64            
╞═══════════════════════════════╪══════╪═══════════╪═════════════╪══════════╪═════════════╪══════════╪═══════════════╪══════════════╪═════════════════╪═════════════════════╪══════════════════╪══════════════════════╪════════════════╡
 2019,2020,2021,2022,2023,2024  BOS   all        454          27590.15  1351.319946  1430      1245.98999     1185          3.11             2.58                 2.94              2.71                  60.77          
 2019,2020,2021,2022,2023,2024  PHI   all        453          27540.25  1259.869995  1278      1328.959961    1497          2.78             3.26                 2.74              2.9                   60.8           
 2019,2020,2021,2022,2023,2024  CAR   all        452          27429.78  1507.25      1474      1173.410034    1178          3.22             2.58                 3.3               2.57                  60.69          
 2019,2020,2021,2022,2023,2024  DAL   all        453          27557.75  1378.920044  1417      1205.469971    1235          3.09             2.69                 3.0               2.62                  60.83          
 2019,2020,2021,2022,2023,2024  NYI   all        452          27468.3   1235.060059  1279      1275.469971    1278          2.79             2.79                 2.7               2.79                  60.77          
 2019,2020,2021,2022,2023,2024  NSH   all        453          27477.9   1337.890015  1326      1357.589966    1376          2.9              3.0                  2.92              2.96                  60.66          
 2019,2020,2021,2022,2023,2024  CGY   all        454          27574.43  1347.800049  1381      1256.810059    1330          3.0              2.89                 2.93              2.73                  60.74                  
 2019,2020,2021,2022,2023,2024  LAK   all        454          27551.97  1333.219971  1331      1235.550049    1277          2.9              2.78                 2.9               2.69                  60.69                  
 2019,2020,2021,2022,2023,2024  VAN   all        453          27519.18  1276.26001   1399      1326.109985    1397          3.05             3.05                 2.78              2.89                  60.75                  
 2019,2020,2021,2022,2023,2024  ANA   all        455          27609.75  1138.800049  1159      1449.160034    1554          2.52             3.38                 2.47              3.15                  60.68                  
 2019,2020,2021,2022,2023,2024  DET   all        455          27613.32  1203.930054  1241      1402.47998     1550          2.7              3.37                 2.62              3.05                  60.69                  
 2019,2020,2021,2022,2023,2024  OTT   all        455          27577.82  1350.400024  1320      1371.02002     1474          2.87             3.21                 2.94              2.98                  60.61                  
 2019,2020,2021,2022,2023,2024  MIN   all        453          27557.93  1292.089966  1415      1238.73999     1340          3.08             2.92                 2.81              2.7                   60.83                  
 2019,2020,2021,2022,2023,2024  PIT   all        453          27506.68  1406.329956  1439      1307.709961    1371          3.14             2.99                 3.07              2.85                  60.72                  
 2019,2020,2021,2022,2023,2024  BUF   all        453          27470.68  1252.420044  1358      1394.089966    1525          2.97             3.33                 2.74              3.04                  60.64                  
 2019,2020,2021,2022,2023,2024  MTL   all        455          27660.0   1233.48999   1286      1458.719971    1549          2.79             3.36                 2.68              3.16                  60.79                  
 2019,2020,2021,2022,2023,2024  EDM   all        455          27543.68  1499.869995  1567      1258.290039    1346          3.41             2.93                 3.27              2.74                  60.54                  
 2019,2020,2021,2022,2023,2024  WSH   all        453          27534.72  1316.75      1449      1288.650024    1357          3.16             2.96                 2.87              2.81                  60.78                  
 2019,2020,2021,2022,2023,2024  CBJ   all        454          27579.42  1206.550049  1286      1423.719971    1558          2.8              3.39                 2.62              3.1                   60.75                  
 2019,2020,2021,2022,2023,2024  CHI   all        454          27549.48  1120.449951  1184      1402.569946    1567          2.58             3.41                 2.44              3.05                  60.68                  
 2019,2020,2021,2022,2023,2024  FLA   all        453          27482.93  1518.189941  1552      1292.790039    1310          3.39             2.86                 3.31              2.82                  60.67                  
 2019,2020,2021,2022,2023,2024  NYR   all        454          27500.93  1309.280029  1465      1309.890015    1276          3.2              2.78                 2.86              2.86                  60.57                  
 2021,2022,2023,2024            SEA   all        328          19868.17  901.97998    961       940.97998      1030          2.9              3.11                 2.72              2.84                  60.57                  
 2019,2020,2021,2022,2023,2024  WPG   all        455          27521.73  1347.530029  1413      1339.189941    1218          3.08             2.66                 2.94              2.92                  60.49                  
 2019,2020,2021,2022,2023,2024  COL   all        454          27520.2   1411.180054  1590      1227.48999     1259          3.47             2.74                 3.08              2.68                  60.62                  
 2019,2020,2021,2022,2023,2024  STL   all        455          27588.88  1224.920044  1440      1327.410034    1372          3.13             2.98                 2.66              2.89                  60.63                  
 2019,2020,2021,2022,2023,2024  NJD   all        453          27486.77  1372.27002   1368      1315.619995    1438          2.99             3.14                 3.0               2.87                  60.68                  
 2019,2020,2021,2022,2023,2024  TOR   all        454          27537.9   1479.26001   1577      1294.400024    1332          3.44             2.9                  3.22              2.82                  60.66                  
 2019,2020,2021,2022,2023,2024  TBL   all        454          27515.25  1430.930054  1563      1306.390015    1300          3.41             2.83                 3.12              2.85                  60.61                  
 2019,2020,2021,2022,2023       ARI   all        372          22584.72  961.919983   1025      1173.189941    1235          2.72             3.28                 2.56              3.12                  60.71                  
 2019,2020,2021,2022,2023,2024  SJS   all        454          27546.48  1203.199951  1158      1454.609985    1633          2.52             3.56                 2.62              3.17                  60.68                  
 2019,2020,2021,2022,2023,2024  VGK   all        455          27630.25  1404.969971  1480      1253.349976    1257          3.21             2.73                 3.05              2.72                  60.73                  
 2024                           UTA   all        82           4994.22   261.690002   240       240.179993     247           2.88             2.97                 3.14              2.89                  60.91                  
└───────────────────────────────┴──────┴───────────┴─────────────┴──────────┴─────────────┴──────────┴───────────────┴──────────────┴─────────────────┴─────────────────────┴──────────────────┴──────────────────────┴────────────────┘  

Game-by-Game Statistics

In addition to season summaries, this library also makes available game-by-game statistics at the skater-, goalie-, or team-level.

DISCLAIMER: Game-by-game data for skaters and goalies is currently only available for the 2024 and 2025 seasons. As of November 2025, the data source I use does not maintain this data consistently for any of the previous seasons.

To get game-by-game stats for specific skaters in a specified date range:

>>> import pyhockey
>>> # The `name` parameter accepts both full and partial player names
>>> pyhockey.skater_games(name=['Auston Matthews', 'Nylander', 'Kni'], start_date='2025-10-10', end_date='2025-10-25')
shape: (23, 22)
┌──────────────────┬────────┬────────────┬────────┬──────┬──────────┬───────────┬─────────┬───────┬────────────────┬──────────────────┬───────┬──────────────────┬──────────┬──────────────┬────────────┬───────────┬───────────────┬─────────────┬──────────┬─────────────┬────────────┐
 name              gameID  gameDate    season  team  position  situation  iceTime  goals  primaryAssists  secondaryAssists  shots  individualxGoals  goalsFor  goalsAgainst  goalsShare  xGoalsFor  xGoalsAgainst  xGoalsShare  corsiFor  corsiAgaint  corsiShare 
 ---               ---     ---         ---     ---   ---       ---        ---      ---    ---             ---               ---    ---               ---       ---           ---         ---        ---            ---          ---       ---          ---        
 str               i32     date        i32     str   str       str        f64      i32    i32             i32               i32    f64               i32       i32           f64         f64        f64            f64          i32       i32          f64        
╞══════════════════╪════════╪════════════╪════════╪══════╪══════════╪═══════════╪═════════╪═══════╪════════════════╪══════════════════╪═══════╪══════════════════╪══════════╪══════════════╪════════════╪═══════════╪═══════════════╪═════════════╪══════════╪═════════════╪════════════╡
 Auston Matthews   20025   2025-10-11  2025    TOR   C         all        21.68    0      0               0                 6      0.62              0         2             0.0         1.03       1.28           44.59        21        20           51.22      
 Matthew Knies     20025   2025-10-11  2025    TOR   L         all        21.32    0      0               0                 3      0.24              1         2             33.33       1.11       1.52           42.21        21        21           50.0       
 William Nylander  20025   2025-10-11  2025    TOR   R         all        21.22    0      0               1                 0      0.04              1         2             33.33       0.67       1.62           29.26        18        23           43.9       
 Auston Matthews   20043   2025-10-13  2025    TOR   C         all        21.3     0      0               0                 8      0.9               2         1             66.67       1.58       0.35           81.87        39        11           78.0       
 Matthew Knies     20043   2025-10-13  2025    TOR   L         all        21.15    1      1               0                 3      0.26              2         1             66.67       1.58       0.35           81.87        38        11           77.55      
                                                                                                                                                                                                                                            
 Auston Matthews   20123   2025-10-24  2025    TOR   C         all        23.8     1      0               0                 5      0.28              2         1             66.67       1.08       1.16           48.21        28        24           53.85      
 Matthew Knies     20123   2025-10-24  2025    TOR   L         all        19.05    0      0               0                 1      0.08              1         2             33.33       0.82       0.79           50.93        26        21           55.32      
 William Nylander  20123   2025-10-24  2025    TOR   R         all        17.65    1      0               0                 2      0.2               2         0             100.0       0.7        0.86           44.87        18        15           54.55      
 Auston Matthews   20132   2025-10-25  2025    TOR   C         all        23.4     0      0               1                 2      0.13              1         1             50.0        0.61       1.36           30.96        18        23           43.9       
 Matthew Knies     20132   2025-10-25  2025    TOR   L         all        22.43    0      1               1                 0      0.0               2         1             66.67       1.44       0.7            67.29        20        15           57.14      
└──────────────────┴────────┴────────────┴────────┴──────┴──────────┴───────────┴─────────┴───────┴────────────────┴──────────────────┴───────┴──────────────────┴──────────┴──────────────┴────────────┴───────────┴───────────────┴─────────────┴──────────┴─────────────┴────────────┘

Getting game-by-game stats for goalie works similarly:

>>> import pyhockey
>>> goalie_games(name=['Stolarz', 'Shesterkin'], season=2025, situation='pk')
shape: (16, 10)
┌─────────────────┬────────┬────────────┬────────┬──────┬───────────┬─────────┬──────────────┬──────────────┬───────────────┐
 name             gameID  gameDate    season  team  situation  iceTime  shotsAgainst  goalsAgainst  xGoalsAgainst 
 ---              ---     ---         ---     ---   ---        ---      ---           ---           ---           
 str              i32     date        i32     str   str        f64      i32           i32           f64           
╞═════════════════╪════════╪════════════╪════════╪══════╪═══════════╪═════════╪══════════════╪══════════════╪═══════════════╡
 Igor Shesterkin  20002   2025-10-07  2025    NYR   pk         2.0      0             0             0.0           
 Igor Shesterkin  20009   2025-10-09  2025    NYR   pk         8.0      9             0             1.07          
 Igor Shesterkin  20029   2025-10-11  2025    NYR   pk         8.0      3             0             0.81          
 Igor Shesterkin  20051   2025-10-14  2025    NYR   pk         0.0      0             0             0.0           
 Igor Shesterkin  20061   2025-10-16  2025    NYR   pk         3.8      6             1             1.01          
                                                                                                        
 Anthony Stolarz  20061   2025-10-16  2025    TOR   pk         6.0      8             0             1.56          
 Anthony Stolarz  20079   2025-10-18  2025    TOR   pk         3.85     3             1             0.47          
 Anthony Stolarz  20098   2025-10-21  2025    TOR   pk         3.88     8             1             1.5           
 Anthony Stolarz  20123   2025-10-24  2025    TOR   pk         0.35     0             0             0.0           
 Anthony Stolarz  20151   2025-10-28  2025    TOR   pk         5.92     4             0             0.81          
└─────────────────┴────────┴────────────┴────────┴──────┴───────────┴─────────┴──────────────┴──────────────┴───────────────┘

And getting game-by-game summaries for teams also works:

>>> import pyhockey
>>> pyhockey.team_games(team=['TOR', 'OTT'], season=2025, end_date='2025-10-25')
shape: (18, 15)
┌──────┬────────┬────────────┬────────────┬────────────┬─────────┬───────────┬───────────┬───────────────┬─────────────┬────────────┬──────────┬──────────────┬───────────────────┬───────────────────────┐
 team  season  gameID      gameDate    isHomeTeam  iceTime  situation  xGoalsFor  xGoalsAgainst  xGoalsShare  corsiShare  goalsFor  goalsAgainst  penaltyMinutesFor  penaltyMinutesAgainst 
 ---   ---     ---         ---         ---         ---      ---        ---        ---            ---          ---         ---       ---           ---                ---                   
 str   i32     i32         date        bool        f64      str        f64        f64            f64          f64         i32       i32           i32                i32                   
╞══════╪════════╪════════════╪════════════╪════════════╪═════════╪═══════════╪═══════════╪═══════════════╪═════════════╪════════════╪══════════╪══════════════╪═══════════════════╪═══════════════════════╡
 OTT   2025    2025020011  2025-10-09  false       60.0     all        3.5        2.39           0.59         0.58        5         4             20                 22                    
 OTT   2025    2025020027  2025-10-11  false       60.0     all        1.81       2.94           0.38         0.47        2         6             10                 4                     
 OTT   2025    2025020041  2025-10-13  true        60.0     all        3.14       3.31           0.49         0.54        1         4             10                 10                    
 OTT   2025    2025020057  2025-10-15  false       60.0     all        4.42       3.95           0.53         0.65        4         8             10                 12                    
 OTT   2025    2025020063  2025-10-16  true        65.0     all        2.3        3.27           0.41         0.51        3         3             6                  4                     
                                                                                                                                                                            
 TOR   2025    2025020061  2025-10-16  true        60.97    all        2.7        2.36           0.53         0.45        2         1             6                  4                     
 TOR   2025    2025020079  2025-10-18  true        63.1     all        2.87       2.5            0.53         0.54        3         4             4                  8                     
 TOR   2025    2025020098  2025-10-21  true        60.0     all        2.96       3.15           0.48         0.48        2         5             9                  11                    
 TOR   2025    2025020123  2025-10-24  false       60.0     all        2.68       2.94           0.48         0.54        3         5             4                  10                    
 TOR   2025    2025020132  2025-10-25  true        61.47    all        2.2        2.11           0.51         0.47        4         3             13                 11                    
└──────┴────────┴────────────┴────────────┴────────────┴─────────┴───────────┴───────────┴───────────────┴─────────────┴────────────┴──────────┴──────────────┴───────────────────┴───────────────────────┘

Working with the data

If you're prefer working with pandas dataframes as opposed to polars ones, you can use the built-in to_pandas() method to make an easy conversion.

>>> import pyhockey
>>> df = pyhockey.skater_seasons(team='TOR', season=2024)
>>> type(df)
<class 'polars.dataframe.frame.DataFrame'>
# Use `to_pandas()` to convert the results to a pandas dataframe
>>> df = df.to_pandas()
>>> type(df)
<class 'pandas.core.frame.DataFrame'>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyhockey-0.2.0.tar.gz (51.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyhockey-0.2.0-py3-none-any.whl (39.7 kB view details)

Uploaded Python 3

File details

Details for the file pyhockey-0.2.0.tar.gz.

File metadata

  • Download URL: pyhockey-0.2.0.tar.gz
  • Upload date:
  • Size: 51.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyhockey-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8cbb4fc7c727fe2a1b1dd4456147f4ecac7ca8add5be83dd018248e5fd669adb
MD5 92801f56414d4cc03f9d379bddd4a366
BLAKE2b-256 2003a2e3507c5c11f26aaa0967c840839905f8f139e1ba1b95dcd33f0370a8b3

See more details on using hashes here.

File details

Details for the file pyhockey-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pyhockey-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 39.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyhockey-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 82400cfbc1b71338e146c1ecb33eb61c87dc9cb8656f805609a868c79992a472
MD5 3eff401549c657d8985afd386829f68d
BLAKE2b-256 9b03dbdb6f438331cb74e00068f389852ec022dd20b37699b43d145af0ef8639

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page