wsba-hockey 1.2.4__tar.gz → 1.2.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {wsba_hockey-1.2.4/src/wsba_hockey.egg-info → wsba_hockey-1.2.5}/PKG-INFO +1 -1
  2. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/pyproject.toml +1 -1
  3. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/src/wsba_hockey/tools/columns.py +6 -1
  4. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/src/wsba_hockey/wsba_main.py +42 -23
  5. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5/src/wsba_hockey.egg-info}/PKG-INFO +1 -1
  6. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/LICENSE +0 -0
  7. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/README.md +0 -0
  8. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/setup.cfg +0 -0
  9. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/src/wsba_hockey/__init__.py +0 -0
  10. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/src/wsba_hockey/tools/__init__.py +0 -0
  11. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/src/wsba_hockey/tools/agg.py +0 -0
  12. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/src/wsba_hockey/tools/archive/old_scraping.py +0 -0
  13. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/src/wsba_hockey/tools/game_pred.py +0 -0
  14. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/src/wsba_hockey/tools/plotting.py +0 -0
  15. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/src/wsba_hockey/tools/scraping.py +0 -0
  16. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/src/wsba_hockey/tools/utils/__init__.py +0 -0
  17. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/src/wsba_hockey/tools/utils/shared.py +0 -0
  18. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/src/wsba_hockey/tools/xg_model.py +0 -0
  19. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/src/wsba_hockey.egg-info/SOURCES.txt +0 -0
  20. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/src/wsba_hockey.egg-info/dependency_links.txt +0 -0
  21. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/src/wsba_hockey.egg-info/top_level.txt +0 -0
  22. {wsba_hockey-1.2.4 → wsba_hockey-1.2.5}/tests/tests.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wsba_hockey
3
- Version: 1.2.4
3
+ Version: 1.2.5
4
4
  Summary: WeakSide Breakout's complete Python package of access to hockey data, primairly including the scraping of National Hockey League schedule, play-by-play, and shifts information.
5
5
  Author-email: Owen Singh <owenbksingh@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/owensingh38/wsba_hockey/
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "wsba_hockey"
3
- version = "1.2.4"
3
+ version = "1.2.5"
4
4
  authors = [
5
5
  { name="Owen Singh", email="owenbksingh@gmail.com" },
6
6
  ]
@@ -38,6 +38,7 @@ def col_map():
38
38
  'periodDescriptor.maxRegulationPeriods':'period_max_regulation',
39
39
  'periodDescriptor.periodType':'period_type',
40
40
  'gameOutcome.lastPeriodType':'period_type_last',
41
+ 'gameOutcome.otPeriods':'ot_periods',
41
42
  'seriesUrl':'series_url',
42
43
  'seriesStatus.round':'series_round',
43
44
  'seriesStatus.seriesAbbrev':'series_abbr',
@@ -48,7 +49,11 @@ def col_map():
48
49
  'seriesStatus.topSeedTeamAbbrev':'top_seed_team_abbr',
49
50
  'seriesStatus.bottomSeedTeamAbbrev':'bottom_seed_team_abbr',
50
51
  'seriesStatus.topSeedWins':'top_seed_wins',
51
- 'seriesStatus.bottomSeedWins':'bottom_seed_wins'
52
+ 'seriesStatus.bottomSeedWins':'bottom_seed_wins',
53
+ 'clock.timeRemaining':'period_time_remaining',
54
+ 'clock.secondsRemaining':'period_seconds_remaining',
55
+ 'clock.running':'period_clock_running',
56
+ 'clock.inIntermission':'game_in_intermission'
52
57
  },
53
58
  'season_info':{
54
59
  'id':'season',
@@ -85,7 +85,7 @@ CONVERT_TEAM_ABBR = {'L.A':'LAK',
85
85
  'T.B':'TBL',
86
86
  'PHX':'ARI'}
87
87
 
88
- PER_SIXTY = ['Fi','xGi','Gi','A1','A2','P1','P','Si','OZF','NZF','DZF','FF','FA','xGF','xGA','GF','GA','SF','SA','CF','CA','HF','HA','Give','Take','Penl','Penl2','Penl5','Draw','Block','GSAx']
88
+ PER_SIXTY = ['Fi','xGi','Gi','A1','A2','P1','P','Si','OZF','NZF','DZF','FF','FA','xGF','xGA','GF','GA','SF','SA','CF','CA','HF','HA','Give','Take','Penl','Penl2','Penl5','Draw','PIM','Block','GSAx']
89
89
 
90
90
  #Some games in the API are specifically known to cause errors in scraping.
91
91
  #This list is updated as frequently as necessary
@@ -289,7 +289,7 @@ def nhl_scrape_schedule(season:int, start:str = '', end:str = ''):
289
289
  A DataFrame containing the schedule data for the specified season and date range.
290
290
  """
291
291
 
292
- api = "https://api-web.nhle.com/v1/schedule/"
292
+ api = "https://api-web.nhle.com/v1/score/"
293
293
 
294
294
  #If either start or end are blank then find start and endpoints for specified season
295
295
  if start == '' or end == '':
@@ -325,7 +325,7 @@ def nhl_scrape_schedule(season:int, start:str = '', end:str = ''):
325
325
  print(f'Scraping games on {str(inc)[:10]}...')
326
326
 
327
327
  get = rs.get(f'{api}{str(inc)[:10]}').json()
328
- gameWeek = pd.json_normalize(list(pd.json_normalize(get['gameWeek'])['games'])[0])
328
+ gameWeek = pd.json_normalize(get['games']).drop(columns=['goals'],errors='ignore')
329
329
 
330
330
  #Return nothing if there's nothing
331
331
  if gameWeek.empty:
@@ -382,35 +382,54 @@ def nhl_scrape_season(season:int, split_shifts:bool = False, season_types:list[i
382
382
  """
383
383
 
384
384
  #Determine whether to use schedule data in repository or to scrape
385
+ local_failed = False
386
+
385
387
  if local:
386
- load = pd.read_csv(local_path)
387
- load['date'] = pd.to_datetime(load['date'])
388
-
389
- if start == '' or end == '':
390
- season_data = rs.get('https://api.nhle.com/stats/rest/en/season').json()['data']
391
- season_data = [s for s in season_data if s['id'] == season][0]
392
- start = season_data['startDate'][0:10]
393
- end = season_data['endDate'][0:10]
394
-
388
+ try:
389
+ load = pd.read_csv(local_path)
390
+ load['game_date'] = pd.to_datetime(load['game_date'])
391
+
392
+ if start == '' or end == '':
393
+ season_data = rs.get('https://api.nhle.com/stats/rest/en/season').json()['data']
394
+ season_data = [s for s in season_data if s['id'] == season][0]
395
+
396
+ season_start = season_data['startDate'][0:10]
397
+ season_end = season_data['endDate'][0:10]
398
+
399
+ else:
400
+ season_start = f'{(str(season)[0:4] if int(start[0:2])>=9 else str(season)[4:8])}-{start[0:2]}-{start[3:5]}'
401
+ season_end = f'{(str(season)[0:4] if int(end[0:2])>=9 else str(season)[4:8])}-{end[0:2]}-{end[3:5]}'
402
+
395
403
  form = '%Y-%m-%d'
396
404
 
397
405
  #Create datetime values from dates
398
- start = datetime.strptime(start,form)
399
- end = datetime.strptime(end,form)
400
-
401
- else:
402
- start = f'{(str(season)[0:4] if int(start[0:2])>=9 else str(season)[4:8])}-{start[0:2]}-{start[3:5]}'
403
- end = f'{(str(season)[0:4] if int(end[0:2])>=9 else str(season)[4:8])}-{end[0:2]}-{end[3:5]}'
406
+ start_date = datetime.strptime(season_start,form)
407
+ end_date = datetime.strptime(season_end,form)
408
+
409
+ load = load.loc[(load['season']==season)&
410
+ (load['season_type'].isin(season_types))&
411
+ (load['game_date']>=start_date)&(load['game_date']<=end_date)&
412
+ (load['game_schedule_state']=='OK')&
413
+ (load['game_state']!='FUT')
414
+ ]
404
415
 
416
+ game_ids = load['game_id'].to_list()
417
+ except KeyError:
418
+ #If loading games locally fails then force a scrape
419
+ local_failed = True
420
+ print('Loading games locally has failed. Loading schedule data with a scrape...')
421
+ else:
422
+ local_failed = True
423
+
424
+ if local_failed:
425
+ load = nhl_scrape_schedule(season,start,end)
405
426
  load = load.loc[(load['season']==season)&
406
427
  (load['season_type'].isin(season_types))&
407
- (load['game_date']>=start)&(load['game_date']<=end)]
428
+ (load['game_schedule_state']=='OK')&
429
+ (load['game_state']!='FUT')
430
+ ]
408
431
 
409
432
  game_ids = load['game_id'].to_list()
410
- else:
411
- load = nhl_scrape_schedule(season,start,end)
412
- load = load.loc[(load['season']==season)&(load['season_type'].isin(season_types))]
413
- game_ids = load['game_id'].to_list()
414
433
 
415
434
  #If no games found, terminate the process
416
435
  if not game_ids:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wsba_hockey
3
- Version: 1.2.4
3
+ Version: 1.2.5
4
4
  Summary: WeakSide Breakout's complete Python package of access to hockey data, primairly including the scraping of National Hockey League schedule, play-by-play, and shifts information.
5
5
  Author-email: Owen Singh <owenbksingh@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/owensingh38/wsba_hockey/
File without changes
File without changes
File without changes
File without changes