wsba-hockey 1.2.4__py3-none-any.whl → 1.2.5__py3-none-any.whl
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.
- wsba_hockey/tools/columns.py +6 -1
- wsba_hockey/wsba_main.py +42 -23
- {wsba_hockey-1.2.4.dist-info → wsba_hockey-1.2.5.dist-info}/METADATA +1 -1
- {wsba_hockey-1.2.4.dist-info → wsba_hockey-1.2.5.dist-info}/RECORD +7 -7
- {wsba_hockey-1.2.4.dist-info → wsba_hockey-1.2.5.dist-info}/WHEEL +0 -0
- {wsba_hockey-1.2.4.dist-info → wsba_hockey-1.2.5.dist-info}/licenses/LICENSE +0 -0
- {wsba_hockey-1.2.4.dist-info → wsba_hockey-1.2.5.dist-info}/top_level.txt +0 -0
wsba_hockey/tools/columns.py
CHANGED
|
@@ -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',
|
wsba_hockey/wsba_main.py
CHANGED
|
@@ -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/
|
|
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(
|
|
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
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
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['
|
|
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.
|
|
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,8 +1,8 @@
|
|
|
1
1
|
wsba_hockey/__init__.py,sha256=DozjAXICrGwXBCF1ej2rgRZw6BtYtNimLqddD0gO4gM,595
|
|
2
|
-
wsba_hockey/wsba_main.py,sha256=
|
|
2
|
+
wsba_hockey/wsba_main.py,sha256=ooD8qjZGJPGRi6uomCw0OMcH48htPuE34kzK8u_N35k,76963
|
|
3
3
|
wsba_hockey/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
wsba_hockey/tools/agg.py,sha256=OkIYd-ApvGVYe2JJLOI21jnDIN5LH8nkeH7eo0reWFI,23364
|
|
5
|
-
wsba_hockey/tools/columns.py,sha256=
|
|
5
|
+
wsba_hockey/tools/columns.py,sha256=XR-yRlEmTWYuzRBk07YpKRCA-Co11R64S4yfYgIrrGM,14310
|
|
6
6
|
wsba_hockey/tools/game_pred.py,sha256=OGh6o1vIcyLUixU80hOO0RPGNmDSY1cvvCNZFcP0wL4,1308
|
|
7
7
|
wsba_hockey/tools/plotting.py,sha256=Ix-Kj-FEP4_uwSwyb5lIRj3tOFdO1z7XUjWManAkY24,6013
|
|
8
8
|
wsba_hockey/tools/scraping.py,sha256=6_GyF8o56fuijTosm4x4OSrvpL61ZygluK2A26XajqU,52246
|
|
@@ -10,8 +10,8 @@ wsba_hockey/tools/xg_model.py,sha256=rY6D1YMuSZkORqHd8ZCp-2gBmH9KUG0DoyHEiXpzWlg
|
|
|
10
10
|
wsba_hockey/tools/archive/old_scraping.py,sha256=hEjMI1RtfeZnf0RBiJFI38oXkLZ3WofeH5xqcF4pzgM,49585
|
|
11
11
|
wsba_hockey/tools/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
wsba_hockey/tools/utils/shared.py,sha256=KxeQVttGem73yncAlnuZvTclqpJpoerTKtLusRh5zsk,2472
|
|
13
|
-
wsba_hockey-1.2.
|
|
14
|
-
wsba_hockey-1.2.
|
|
15
|
-
wsba_hockey-1.2.
|
|
16
|
-
wsba_hockey-1.2.
|
|
17
|
-
wsba_hockey-1.2.
|
|
13
|
+
wsba_hockey-1.2.5.dist-info/licenses/LICENSE,sha256=Nr_Um1Pd5FQJTWWgm7maZArdtYMbDhzXYSwyJIZDGik,1114
|
|
14
|
+
wsba_hockey-1.2.5.dist-info/METADATA,sha256=8ixTFSlyTLzdcXCVt_F4ZNrRzvgSgyc7O6_0FYSCOzo,3592
|
|
15
|
+
wsba_hockey-1.2.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
16
|
+
wsba_hockey-1.2.5.dist-info/top_level.txt,sha256=acU7s3x-RZC1zGiqCOmO0g267iqCg34lzIfdmYxxGmQ,12
|
|
17
|
+
wsba_hockey-1.2.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|