wsba-hockey 1.1.9__py3-none-any.whl → 1.2.1__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/scraping.py +146 -170
- wsba_hockey/tools/utils/__init__.py +0 -1
- wsba_hockey/tools/utils/shared.py +14 -389
- wsba_hockey/tools/xg_model.py +6 -1
- wsba_hockey/wsba_main.py +47 -14
- {wsba_hockey-1.1.9.dist-info → wsba_hockey-1.2.1.dist-info}/METADATA +16 -15
- wsba_hockey-1.2.1.dist-info/RECORD +15 -0
- wsba_hockey/api/api/index.py +0 -162
- wsba_hockey/data_pipelines.py +0 -247
- wsba_hockey/evidence/weakside-breakout/node_modules/duckdb/vendor.py +0 -146
- wsba_hockey/evidence/weakside-breakout/node_modules/flatted/python/flatted.py +0 -149
- wsba_hockey/evidence/weakside-breakout/node_modules/flatted/python/test.py +0 -63
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/gyp_main.py +0 -45
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +0 -367
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +0 -206
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +0 -1270
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +0 -1547
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +0 -59
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +0 -153
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +0 -271
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +0 -574
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +0 -690
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/common.py +0 -661
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +0 -78
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +0 -165
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +0 -109
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +0 -55
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +0 -808
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +0 -1173
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +0 -1321
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +0 -120
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +0 -103
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +0 -464
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +0 -89
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +0 -58
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +0 -2714
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +0 -3981
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +0 -44
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +0 -2936
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +0 -55
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +0 -1394
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +0 -25
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/input.py +0 -3130
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +0 -98
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +0 -771
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +0 -1271
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +0 -174
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +0 -61
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +0 -374
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +0 -1939
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +0 -302
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +0 -3197
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +0 -65
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/test_gyp.py +0 -261
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/graphviz.py +0 -102
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/pretty_gyp.py +0 -156
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/pretty_sln.py +0 -181
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/pretty_vcproj.py +0 -339
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/test/fixtures/test-charmap.py +0 -31
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/update-gyp.py +0 -64
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/gyp_main.py +0 -45
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +0 -367
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +0 -206
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +0 -1270
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +0 -1547
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +0 -59
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +0 -153
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +0 -271
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +0 -574
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +0 -666
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/common.py +0 -654
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +0 -78
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +0 -165
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +0 -109
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +0 -55
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +0 -808
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +0 -1173
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +0 -1321
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +0 -120
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +0 -103
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +0 -464
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +0 -89
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +0 -58
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +0 -2518
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +0 -3978
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +0 -44
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +0 -2936
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +0 -55
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +0 -1394
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +0 -25
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/input.py +0 -3137
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +0 -98
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +0 -771
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +0 -1271
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +0 -174
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +0 -61
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +0 -374
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +0 -1939
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +0 -302
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +0 -3197
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +0 -65
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/setup.py +0 -42
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/test_gyp.py +0 -260
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/graphviz.py +0 -102
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/pretty_gyp.py +0 -156
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/pretty_sln.py +0 -181
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/pretty_vcproj.py +0 -339
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/test/fixtures/test-charmap.py +0 -31
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/update-gyp.py +0 -46
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/duos/app.py +0 -210
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/duos/calc.py +0 -163
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/game_stats/app.py +0 -401
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/game_stats/name_fix.py +0 -47
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/goalie/app.py +0 -101
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/goalie/plot.py +0 -71
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/goalie/rink_plot.py +0 -245
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/heatmaps/app.py +0 -108
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/heatmaps/plot.py +0 -95
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/heatmaps/rink_plot.py +0 -245
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/line-combos/app.py +0 -245
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/line-combos/plot.py +0 -275
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/line-combos/rink_plot.py +0 -245
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/matchups/app.py +0 -145
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/matchups/plot.py +0 -79
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/matchups/rink_plot.py +0 -245
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/pbp/app.py +0 -406
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/pbp/plot.py +0 -79
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/pbp/rink_plot.py +0 -245
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/skater/app.py +0 -110
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/skater/plot.py +0 -59
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/skater/rink_plot.py +0 -245
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/team_heatmaps/app.py +0 -103
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/team_heatmaps/plot.py +0 -95
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/team_heatmaps/rink_plot.py +0 -245
- wsba_hockey/flask/app.py +0 -77
- wsba_hockey/tools/utils/config.py +0 -14
- wsba_hockey/tools/utils/save_pages.py +0 -133
- wsba_hockey/workspace.py +0 -28
- wsba_hockey-1.1.9.dist-info/RECORD +0 -148
- {wsba_hockey-1.1.9.dist-info → wsba_hockey-1.2.1.dist-info}/WHEEL +0 -0
- {wsba_hockey-1.1.9.dist-info → wsba_hockey-1.2.1.dist-info}/licenses/LICENSE +0 -0
- {wsba_hockey-1.1.9.dist-info → wsba_hockey-1.2.1.dist-info}/top_level.txt +0 -0
@@ -1,210 +0,0 @@
|
|
1
|
-
import pandas as pd
|
2
|
-
import pyarrow.dataset as ds
|
3
|
-
import numpy as np
|
4
|
-
import calc
|
5
|
-
import requests as rs
|
6
|
-
from urllib.parse import *
|
7
|
-
from shiny import *
|
8
|
-
from shinywidgets import output_widget, render_widget
|
9
|
-
|
10
|
-
app_ui = ui.page_fluid(
|
11
|
-
ui.tags.link(
|
12
|
-
rel='stylesheet',
|
13
|
-
href='https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap'
|
14
|
-
),
|
15
|
-
ui.tags.style(
|
16
|
-
"""
|
17
|
-
body {
|
18
|
-
background-color: #09090b;
|
19
|
-
color: white;
|
20
|
-
font-family: 'Bebas Neue', sans-serif;
|
21
|
-
}
|
22
|
-
|
23
|
-
.custom-input input.form-control,
|
24
|
-
.custom-input .selectize-control,
|
25
|
-
.custom-input .selectize-input {
|
26
|
-
background-color: #09090b !important; /* black background */
|
27
|
-
color: white !important; /* white font color */
|
28
|
-
border-radius: 4px;
|
29
|
-
border: 1px solid #444;
|
30
|
-
}
|
31
|
-
|
32
|
-
.custom-input .selectize-dropdown,
|
33
|
-
.custom-input .selectize-dropdown-content {
|
34
|
-
background-color: #09090b !important;
|
35
|
-
color: white !important;
|
36
|
-
}
|
37
|
-
|
38
|
-
.custom-input .selectize-control.multi .item {
|
39
|
-
background-color: #09090b !important;
|
40
|
-
color: white !important;
|
41
|
-
border-radius: 4px;
|
42
|
-
padding: 2px 6px;
|
43
|
-
margin: 2px 4px 2px 0;
|
44
|
-
}
|
45
|
-
|
46
|
-
label.control-label {
|
47
|
-
color: white !important;
|
48
|
-
}
|
49
|
-
|
50
|
-
.selectize-control.multi {
|
51
|
-
width: 300px !important;
|
52
|
-
}
|
53
|
-
|
54
|
-
.form-row {
|
55
|
-
display: flex;
|
56
|
-
gap: 12px;
|
57
|
-
flex-wrap: wrap;
|
58
|
-
justify-content: center;
|
59
|
-
}
|
60
|
-
|
61
|
-
.submit-button {
|
62
|
-
display: flex;
|
63
|
-
justify-content: center;
|
64
|
-
}
|
65
|
-
|
66
|
-
.hide {
|
67
|
-
display: none;
|
68
|
-
}
|
69
|
-
|
70
|
-
.table thead tr {
|
71
|
-
white-space: nowrap;
|
72
|
-
text-align: center;
|
73
|
-
color: white;
|
74
|
-
background-color: #09090b;
|
75
|
-
}
|
76
|
-
|
77
|
-
.table thead th {
|
78
|
-
white-space: nowrap;
|
79
|
-
text-align: center;
|
80
|
-
color: #09090b;
|
81
|
-
}
|
82
|
-
|
83
|
-
.table tbody tr {
|
84
|
-
--bs-table-bg: #09090b;
|
85
|
-
--bs-table-color-state: white;
|
86
|
-
}
|
87
|
-
|
88
|
-
.table tbody tr td {
|
89
|
-
white-space: nowrap;
|
90
|
-
text-align: center;
|
91
|
-
overflow: hidden;
|
92
|
-
text-overflow: ellipsis;
|
93
|
-
color: white;
|
94
|
-
background-color: #09090b;
|
95
|
-
}
|
96
|
-
"""
|
97
|
-
),
|
98
|
-
ui.output_data_frame("duos")
|
99
|
-
)
|
100
|
-
|
101
|
-
def server(input, output, session):
|
102
|
-
col = [
|
103
|
-
'season','season_type','game_id','game_date',
|
104
|
-
'away_team_abbr','home_team_abbr','event_num','period',
|
105
|
-
'seconds_elapsed',"strength_state","strength_state_venue",
|
106
|
-
"event_type","description",
|
107
|
-
"penalty_duration",
|
108
|
-
"event_team_abbr","event_team_venue",
|
109
|
-
"x_adj","y_adj",
|
110
|
-
"event_distance","event_angle","event_length","seconds_since_last",
|
111
|
-
"away_on_1_id","away_on_2_id","away_on_3_id","away_on_4_id","away_on_5_id","away_on_6_id","away_goalie_id",
|
112
|
-
"home_on_1_id","home_on_2_id","home_on_3_id","home_on_4_id","home_on_5_id","home_on_6_id","home_goalie_id",
|
113
|
-
'rush','rebound','empty_net','xG'
|
114
|
-
]
|
115
|
-
|
116
|
-
@output()
|
117
|
-
@render.data_frame
|
118
|
-
def duos():
|
119
|
-
#Retreive query parameters
|
120
|
-
search = session.input[".clientdata_url_search"]()
|
121
|
-
query = parse_qs(urlparse(search).query)
|
122
|
-
|
123
|
-
print(query)
|
124
|
-
#If no input data is provided automatically provide a select skater and plot all 5v5 fenwick shots
|
125
|
-
defaults = {
|
126
|
-
'season':['20182019'],
|
127
|
-
'team':['BOS'],
|
128
|
-
'strength_state':['5v5'],
|
129
|
-
'season_type':['2'],
|
130
|
-
'skaters':['8473419,8470638']
|
131
|
-
}
|
132
|
-
|
133
|
-
for key in defaults.keys():
|
134
|
-
if key not in query.keys():
|
135
|
-
query.update({key:defaults[key]})
|
136
|
-
|
137
|
-
#Iterate through query and parse params with multiple selections
|
138
|
-
for param in query.keys():
|
139
|
-
q_string = query[param][0]
|
140
|
-
query[param] = q_string.split(',')
|
141
|
-
|
142
|
-
print(query)
|
143
|
-
#Determine which season to load based on the input
|
144
|
-
season = query['season'][0]
|
145
|
-
|
146
|
-
#Load appropriate dataframe
|
147
|
-
dataset = ds.dataset(f's3://weakside-breakout/pbp/parquet/nhl_pbp_{season}.parquet', format='parquet')
|
148
|
-
filter_expr = ((ds.field('away_team_abbr') == query['team'][0]) | (ds.field('home_team_abbr') == query['team'][0])) & ((ds.field('season_type') == int(query['season_type'][0])))
|
149
|
-
|
150
|
-
table = dataset.to_table(columns=col,filter=filter_expr)
|
151
|
-
df = table.to_pandas()
|
152
|
-
|
153
|
-
#Prepare dataframe
|
154
|
-
df['home_on_ice'] = df['home_on_1_id'].astype(str) + ";" + df['home_on_2_id'].astype(str) + ";" + df['home_on_3_id'].astype(str) + ";" + df['home_on_4_id'].astype(str) + ";" + df['home_on_5_id'].astype(str) + ";" + df['home_on_6_id'].astype(str)
|
155
|
-
df['away_on_ice'] = df['away_on_1_id'].astype(str) + ";" + df['away_on_2_id'].astype(str) + ";" + df['away_on_3_id'].astype(str) + ";" + df['away_on_4_id'].astype(str) + ";" + df['away_on_5_id'].astype(str) + ";" + df['away_on_6_id'].astype(str)
|
156
|
-
|
157
|
-
df['onice_for'] = np.where(df['home_team_abbr']==df['event_team_abbr'],df['home_on_ice'],df['away_on_ice'])
|
158
|
-
df['onice_against'] = np.where(df['away_team_abbr']==df['event_team_abbr'],df['home_on_ice'],df['away_on_ice'])
|
159
|
-
|
160
|
-
df['onice'] = df['onice_for'] + ';' + df['onice_against']
|
161
|
-
|
162
|
-
skaters = query['skaters']
|
163
|
-
#Four aggregations to be completed:
|
164
|
-
#Team with both players on the ice
|
165
|
-
#Team with each player on the ice without the other
|
166
|
-
#Team with neither player on the ice
|
167
|
-
both = df.loc[(df['onice'].str.contains(skaters[0]))&(df['onice'].str.contains(skaters[1]))]
|
168
|
-
p1 = df.loc[(df['onice'].str.contains(skaters[0]))&(~(df['onice'].str.contains(skaters[1])))]
|
169
|
-
p2 = df.loc[(~(df['onice'].str.contains(skaters[0])))&(df['onice'].str.contains(skaters[1]))]
|
170
|
-
neither = df.loc[~((df['onice'].str.contains(skaters[0]))&(df['onice'].str.contains(skaters[1])))]
|
171
|
-
|
172
|
-
dfs = []
|
173
|
-
if 'Other' in query['strength_state']:
|
174
|
-
strength_state = query['strength_state'] + df.loc[~(df['strength_state'].isin(['5v5','5v4','4v5'])),'strength_state'].drop_duplicates().to_list()
|
175
|
-
else:
|
176
|
-
strength_state = query['strength_state']
|
177
|
-
|
178
|
-
skater_names = {}
|
179
|
-
#Find player names
|
180
|
-
for i in range(2):
|
181
|
-
skater = skaters[i]
|
182
|
-
data = rs.get(f'https://api-web.nhle.com/v1/player/{skater}/landing').json()
|
183
|
-
|
184
|
-
name = data['firstName']['default'].upper() + ' ' + data['lastName']['default'].upper()
|
185
|
-
|
186
|
-
skater_names.update({f'skater{i+1}':name})
|
187
|
-
|
188
|
-
team = query['team'][0]
|
189
|
-
|
190
|
-
#Calculate stats for each df
|
191
|
-
skater1 = skater_names['skater1']
|
192
|
-
skater2 = skater_names['skater2']
|
193
|
-
|
194
|
-
for df, data in zip([both, p1, p2, neither],['With Both',f'With {skater1}, Without {skater2}',f'With {skater2}, Without {skater1}','With Neither']):
|
195
|
-
stats = calc.calculate_stats(df,team,strength_state).replace({team: f'{team} {data}'})
|
196
|
-
dfs.append(stats)
|
197
|
-
|
198
|
-
total = pd.concat(dfs)[['Team',
|
199
|
-
'TOI',
|
200
|
-
'GF/60','GA/60',
|
201
|
-
'SF/60','SA/60',
|
202
|
-
'FF/60','FA/60',
|
203
|
-
'xGF/60','xGA/60',
|
204
|
-
'GF%','SF%',
|
205
|
-
'FF%','xGF%',
|
206
|
-
'GSAx']].round(2)
|
207
|
-
|
208
|
-
return render.DataTable(total)
|
209
|
-
|
210
|
-
app = App(app_ui, server)
|
@@ -1,163 +0,0 @@
|
|
1
|
-
import numpy as np
|
2
|
-
import pandas as pd
|
3
|
-
|
4
|
-
def calc_team(pbp,game_strength):
|
5
|
-
teams = []
|
6
|
-
fenwick_events = ['missed-shot','shot-on-goal','goal']
|
7
|
-
|
8
|
-
for team in [('away','home'),('home','away')]:
|
9
|
-
#Flip strength state (when necessary) and filter by game strength if not "all"
|
10
|
-
if game_strength != "all":
|
11
|
-
if game_strength not in ['3v3','4v4','5v5']:
|
12
|
-
for strength in game_strength:
|
13
|
-
pbp['strength_state'] = np.where(np.logical_and(pbp['event_team_venue']==team[1],pbp['strength_state']==strength[::-1]),strength,pbp['strength_state'])
|
14
|
-
|
15
|
-
pbp = pbp.loc[pbp['strength_state'].isin(game_strength)]
|
16
|
-
|
17
|
-
pbp['xGF'] = np.where(pbp['event_team_abbr'] == pbp[f'{team[0]}_team_abbr'], pbp['xG'], 0)
|
18
|
-
pbp['xGA'] = np.where(pbp['event_team_abbr'] == pbp[f'{team[1]}_team_abbr'], pbp['xG'], 0)
|
19
|
-
pbp['GF'] = np.where((pbp['event_type'] == "goal") & (pbp['event_team_abbr'] == pbp[f'{team[0]}_team_abbr']), 1, 0)
|
20
|
-
pbp['GA'] = np.where((pbp['event_type'] == "goal") & (pbp['event_team_abbr'] == pbp[f'{team[1]}_team_abbr']), 1, 0)
|
21
|
-
pbp['SF'] = np.where((pbp['event_type'].isin(['shot-on-goal','goal'])) & (pbp['event_team_abbr'] == pbp[f'{team[0]}_team_abbr']), 1, 0)
|
22
|
-
pbp['SA'] = np.where((pbp['event_type'].isin(['shot-on-goal','goal'])) & (pbp['event_team_abbr'] == pbp[f'{team[1]}_team_abbr']), 1, 0)
|
23
|
-
pbp['FF'] = np.where((pbp['event_type'].isin(fenwick_events)) & (pbp['event_team_abbr'] == pbp[f'{team[0]}_team_abbr']), 1, 0)
|
24
|
-
pbp['FA'] = np.where((pbp['event_type'].isin(fenwick_events)) & (pbp['event_team_abbr'] == pbp[f'{team[1]}_team_abbr']), 1, 0)
|
25
|
-
pbp['CF'] = np.where((pbp['event_type'].isin(fenwick_events+['blocked-shot'])) & (pbp['event_team_abbr'] == pbp[f'{team[0]}_team_abbr']), 1, 0)
|
26
|
-
pbp['CA'] = np.where((pbp['event_type'].isin(fenwick_events+['blocked-shot'])) & (pbp['event_team_abbr'] == pbp[f'{team[1]}_team_abbr']), 1, 0)
|
27
|
-
pbp['HF'] = np.where((pbp['event_type']=='hit') & (pbp['event_team_abbr'] == pbp[f'{team[0]}_team_abbr']), 1, 0)
|
28
|
-
pbp['HA'] = np.where((pbp['event_type']=='hit') & (pbp['event_team_abbr'] == pbp[f'{team[1]}_team_abbr']), 1, 0)
|
29
|
-
pbp['Penl'] = np.where((pbp['event_type']=='penalty') & (pbp['event_team_abbr'] == pbp[f'{team[0]}_team_abbr']), 1, 0)
|
30
|
-
pbp['Penl2'] = np.where((pbp['event_type']=='penalty') & (pbp['penalty_duration']==2) & (pbp['event_team_abbr'] == pbp[f'{team[0]}_team_abbr']), 1, 0)
|
31
|
-
pbp['Penl5'] = np.where((pbp['event_type']=='penalty') & (pbp['penalty_duration']==5) & (pbp['event_team_abbr'] == pbp[f'{team[0]}_team_abbr']), 1, 0)
|
32
|
-
pbp['PIM'] = np.where((pbp['event_team_abbr'] == pbp[f'{team[0]}_team_abbr']), pbp['penalty_duration'], 0)
|
33
|
-
pbp['Draw'] = np.where((pbp['event_type']=='penalty') & (pbp['event_team_abbr'] == pbp[f'{team[1]}_team_abbr']), 1, 0)
|
34
|
-
pbp['Give'] = np.where((pbp['event_type']=='giveaway') & (pbp['event_team_abbr'] == pbp[f'{team[0]}_team_abbr']), 1, 0)
|
35
|
-
pbp['Take'] = np.where((pbp['event_type']=='takeaway') & (pbp['event_team_abbr'] == pbp[f'{team[0]}_team_abbr']), 1, 0)
|
36
|
-
pbp['Block'] = pbp['CA'] - pbp['FA']
|
37
|
-
pbp['RushF'] = np.where((pbp['event_team_abbr'] == pbp[f'{team[0]}_team_abbr'])&(pbp['rush']>0), 1, 0)
|
38
|
-
pbp['RushA'] = np.where((pbp['event_team_abbr'] == pbp[f'{team[1]}_team_abbr'])&(pbp['rush']>0), 1, 0)
|
39
|
-
pbp['RushFxG'] = np.where((pbp['event_team_abbr'] == pbp[f'{team[0]}_team_abbr'])&(pbp['rush']>0), pbp['xG'], 0)
|
40
|
-
pbp['RushAxG'] = np.where((pbp['event_team_abbr'] == pbp[f'{team[1]}_team_abbr'])&(pbp['rush']>0), pbp['xG'], 0)
|
41
|
-
pbp['RushFG'] = np.where((pbp['event_type'] == "goal") & (pbp['event_team_abbr'] == pbp[f'{team[0]}_team_abbr'])&(pbp['rush']>0), 1, 0)
|
42
|
-
pbp['RushAG'] = np.where((pbp['event_type'] == "goal") & (pbp['event_team_abbr'] == pbp[f'{team[1]}_team_abbr'])&(pbp['rush']>0), 1, 0)
|
43
|
-
|
44
|
-
stats = pbp.groupby([f'{team[0]}_team_abbr','season']).agg(
|
45
|
-
GP=('game_id','nunique'),
|
46
|
-
TOI=('event_length','sum'),
|
47
|
-
FF=('FF', 'sum'),
|
48
|
-
FA=('FA', 'sum'),
|
49
|
-
GF=('GF', 'sum'),
|
50
|
-
GA=('GA', 'sum'),
|
51
|
-
SF=('SF','sum'),
|
52
|
-
SA=('SA','sum'),
|
53
|
-
xGF=('xGF', 'sum'),
|
54
|
-
xGA=('xGA', 'sum'),
|
55
|
-
CF=('CF','sum'),
|
56
|
-
CA=('CA','sum'),
|
57
|
-
HF=('HF','sum'),
|
58
|
-
HA=('HA','sum'),
|
59
|
-
Penl=('Penl','sum'),
|
60
|
-
Penl2=('Penl2','sum'),
|
61
|
-
Penl5=('Penl5','sum'),
|
62
|
-
PIM=('PIM','sum'),
|
63
|
-
Draw=('Draw','sum'),
|
64
|
-
Give=('Give','sum'),
|
65
|
-
Take=('Take','sum'),
|
66
|
-
Block=('Block','sum'),
|
67
|
-
RushF=('RushF','sum'),
|
68
|
-
RushA=('RushA','sum'),
|
69
|
-
RushFxG=('RushFxG','sum'),
|
70
|
-
RushAxG=('RushAxG','sum'),
|
71
|
-
RushFG=('RushFG','sum'),
|
72
|
-
RushAG=('RushAG','sum'),
|
73
|
-
).reset_index().rename(columns={f'{team[0]}_team_abbr':"Team",'season':"Season",'game_id':'Game'})
|
74
|
-
teams.append(stats)
|
75
|
-
|
76
|
-
onice_stats = pd.concat(teams).groupby(['Team','Season']).agg(
|
77
|
-
GP=('GP','sum'),
|
78
|
-
TOI=('TOI','sum'),
|
79
|
-
FF=('FF', 'sum'),
|
80
|
-
FA=('FA', 'sum'),
|
81
|
-
GF=('GF', 'sum'),
|
82
|
-
GA=('GA', 'sum'),
|
83
|
-
SF=('SF','sum'),
|
84
|
-
SA=('SA','sum'),
|
85
|
-
xGF=('xGF', 'sum'),
|
86
|
-
xGA=('xGA', 'sum'),
|
87
|
-
CF=('CF','sum'),
|
88
|
-
CA=('CA','sum'),
|
89
|
-
HF=('HF','sum'),
|
90
|
-
HA=('HA','sum'),
|
91
|
-
Penl=('Penl','sum'),
|
92
|
-
Penl2=('Penl2','sum'),
|
93
|
-
Penl5=('Penl5','sum'),
|
94
|
-
PIM=('PIM','sum'),
|
95
|
-
Draw=('Draw','sum'),
|
96
|
-
Give=('Give','sum'),
|
97
|
-
Take=('Take','sum'),
|
98
|
-
Block=('Block','sum'),
|
99
|
-
RushF=('RushF','sum'),
|
100
|
-
RushA=('RushA','sum'),
|
101
|
-
RushFxG=('RushFxG','sum'),
|
102
|
-
RushAxG=('RushAxG','sum'),
|
103
|
-
RushFG=('RushFG','sum'),
|
104
|
-
RushAG=('RushAG','sum'),
|
105
|
-
).reset_index()
|
106
|
-
|
107
|
-
for col in onice_stats.columns.to_list()[2:30]:
|
108
|
-
onice_stats[col] = onice_stats[col].astype(float)
|
109
|
-
|
110
|
-
onice_stats['ShF%'] = onice_stats['GF']/onice_stats['SF']
|
111
|
-
onice_stats['xGF/FF'] = onice_stats['xGF']/onice_stats['FF']
|
112
|
-
onice_stats['GF/xGF'] = onice_stats['GF']/onice_stats['xGF']
|
113
|
-
onice_stats['FshF%'] = onice_stats['GF']/onice_stats['FF']
|
114
|
-
onice_stats['ShA%'] = onice_stats['GA']/onice_stats['SA']
|
115
|
-
onice_stats['xGA/FA'] = onice_stats['xGA']/onice_stats['FA']
|
116
|
-
onice_stats['GA/xGA'] = onice_stats['GA']/onice_stats['xGA']
|
117
|
-
onice_stats['FshA%'] = onice_stats['GA']/onice_stats['FA']
|
118
|
-
onice_stats['PM%'] = onice_stats['Take']/(onice_stats['Give']+onice_stats['Take'])
|
119
|
-
onice_stats['HF%'] = onice_stats['HF']/(onice_stats['HF']+onice_stats['HA'])
|
120
|
-
onice_stats['PENL%'] = onice_stats['Draw']/(onice_stats['Draw']+onice_stats['Penl'])
|
121
|
-
onice_stats['GSAx'] = onice_stats['xGA']-onice_stats['GA']
|
122
|
-
|
123
|
-
return onice_stats
|
124
|
-
|
125
|
-
|
126
|
-
def calculate_stats(pbp,team,game_strength):
|
127
|
-
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']
|
128
|
-
|
129
|
-
complete = calc_team(pbp,game_strength)
|
130
|
-
|
131
|
-
#WSBA
|
132
|
-
complete['WSBA'] = complete['Team']+complete['Season'].astype(str)
|
133
|
-
|
134
|
-
#Set TOI to minute
|
135
|
-
complete['TOI'] = complete['TOI']/60
|
136
|
-
|
137
|
-
#Add per 60 stats
|
138
|
-
for stat in per_sixty[11:len(per_sixty)]:
|
139
|
-
complete[f'{stat}/60'] = (complete[stat]/complete['TOI'])*60
|
140
|
-
|
141
|
-
complete['GF%'] = complete['GF']/(complete['GF']+complete['GA'])
|
142
|
-
complete['SF%'] = complete['SF']/(complete['SF']+complete['SA'])
|
143
|
-
complete['xGF%'] = complete['xGF']/(complete['xGF']+complete['xGA'])
|
144
|
-
complete['FF%'] = complete['FF']/(complete['FF']+complete['FA'])
|
145
|
-
complete['CF%'] = complete['CF']/(complete['CF']+complete['CA'])
|
146
|
-
|
147
|
-
head = ['Team','Game'] if 'Game' in complete.columns else ['Team']
|
148
|
-
complete = complete[head+[
|
149
|
-
'Season','WSBA',
|
150
|
-
'GP','TOI',
|
151
|
-
"GF","SF","FF","xGF","xGF/FF","GF/xGF","ShF%","FshF%",
|
152
|
-
"GA","SA","FA","xGA","xGA/FA","GA/xGA","ShA%","FshA%",
|
153
|
-
'CF','CA',
|
154
|
-
'GF%','SF%','FF%','xGF%','CF%',
|
155
|
-
'HF','HA','HF%',
|
156
|
-
'Penl','Penl2','Penl5','PIM','Draw','PENL%',
|
157
|
-
'Give','Take','PM%',
|
158
|
-
'Block',
|
159
|
-
'RushF','RushA','RushFxG','RushAxG','RushFG','RushAG',
|
160
|
-
'GSAx'
|
161
|
-
]+[f'{stat}/60' for stat in per_sixty[11:len(per_sixty)]]]
|
162
|
-
|
163
|
-
return complete.loc[complete['Team']==team]
|