nfelodcm 0.1.4__py3-none-any.whl → 0.1.7__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.
- nfelodcm/nfelodcm/Engine/Assignments/assignment.py +15 -1
- nfelodcm/nfelodcm/Engine/Assignments/assignments/__init__.py +2 -0
- nfelodcm/nfelodcm/Engine/Assignments/assignments/desc_based_plays.py +57 -0
- nfelodcm/nfelodcm/Engine/Assignments/assignments/fastr_team_repl.py +9 -0
- nfelodcm/nfelodcm/Engine/Assignments/assignments/penalty_formatting.py +21 -0
- nfelodcm/nfelodcm/Maps/pbp.json +3 -1
- nfelodcm/nfelodcm/nfelodcm.py +22 -1
- {nfelodcm-0.1.4.dist-info → nfelodcm-0.1.7.dist-info}/METADATA +1 -1
- {nfelodcm-0.1.4.dist-info → nfelodcm-0.1.7.dist-info}/RECORD +11 -9
- {nfelodcm-0.1.4.dist-info → nfelodcm-0.1.7.dist-info}/WHEEL +1 -1
- {nfelodcm-0.1.4.dist-info → nfelodcm-0.1.7.dist-info}/top_level.txt +0 -0
@@ -1,10 +1,24 @@
|
|
1
|
-
from .assignments import
|
1
|
+
from .assignments import (
|
2
|
+
game_id_repl, penalty_formatting, desc_based_plays
|
3
|
+
)
|
2
4
|
|
3
5
|
## a dictionary that holds assignments and the columns they add ##
|
4
6
|
assignments = {
|
5
7
|
'game_id_repl' : {
|
6
8
|
'func' : game_id_repl,
|
7
9
|
'new_columns' : []
|
10
|
+
},
|
11
|
+
'penalty_formatting' : {
|
12
|
+
'func' : penalty_formatting,
|
13
|
+
'new_columns' : []
|
14
|
+
},
|
15
|
+
'desc_based_plays' : {
|
16
|
+
'func' : desc_based_plays,
|
17
|
+
'new_columns' : [
|
18
|
+
('qb_dropback_all', 'float32'),
|
19
|
+
('rush_attempt_all', 'float32'),
|
20
|
+
('play_call', 'str'),
|
21
|
+
]
|
8
22
|
}
|
9
23
|
}
|
10
24
|
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import pandas as pd
|
2
|
+
import numpy
|
3
|
+
|
4
|
+
def desc_based_plays(df):
|
5
|
+
'''
|
6
|
+
Infers play types from description that may show up
|
7
|
+
differently in the standard columns, especially when
|
8
|
+
there is a penalty
|
9
|
+
'''
|
10
|
+
## infer pass play ##
|
11
|
+
df['desc_based_dropback'] = numpy.where(
|
12
|
+
(
|
13
|
+
(df['desc'].str.contains(' pass ', regex=False)) |
|
14
|
+
(df['desc'].str.contains(' sacked', regex=False)) |
|
15
|
+
(df['desc'].str.contains(' scramble', regex=False))
|
16
|
+
),
|
17
|
+
1,
|
18
|
+
0
|
19
|
+
)
|
20
|
+
## infer run ##
|
21
|
+
df['desc_based_run'] = numpy.where(
|
22
|
+
(
|
23
|
+
(~df['desc'].str.contains(' pass ', regex=False, na=False)) &
|
24
|
+
(~df['desc'].str.contains(' sacked', regex=False, na=False)) &
|
25
|
+
(~df['desc'].str.contains(' scramble', regex=False, na=False)) &
|
26
|
+
(~df['desc'].str.contains(' kicks ', regex=False, na=False)) &
|
27
|
+
(~df['desc'].str.contains(' punts ', regex=False, na=False)) &
|
28
|
+
(~df['desc'].str.contains(' field goal ', regex=False, na=False)) &
|
29
|
+
(df['desc'].str.contains(' to ', regex=False)) &
|
30
|
+
(df['desc'].str.contains(' for ', regex=False))
|
31
|
+
),
|
32
|
+
1,
|
33
|
+
0
|
34
|
+
)
|
35
|
+
## add new cols ##
|
36
|
+
df['qb_dropback_all'] = df[[
|
37
|
+
'qb_dropback', 'desc_based_dropback'
|
38
|
+
]].max(axis=1)
|
39
|
+
df['rush_attempt_all'] = df[[
|
40
|
+
'rush_attempt', 'desc_based_run'
|
41
|
+
]].max(axis=1)
|
42
|
+
## create a specific play call field ##
|
43
|
+
df['play_call'] = numpy.where(
|
44
|
+
df['qb_dropback_all'] == 1,
|
45
|
+
'Pass',
|
46
|
+
numpy.where(
|
47
|
+
df['rush_attempt_all'] == 1,
|
48
|
+
'Run',
|
49
|
+
numpy.nan
|
50
|
+
)
|
51
|
+
)
|
52
|
+
## clean up ##
|
53
|
+
df = df.drop(columns=[
|
54
|
+
'desc_based_dropback', 'desc_based_run'
|
55
|
+
]).copy()
|
56
|
+
## return ##
|
57
|
+
return df
|
@@ -14,6 +14,15 @@ def game_id_repl(df):
|
|
14
14
|
"""
|
15
15
|
df['away_team'] = df['away_team'].replace(repl)
|
16
16
|
df['home_team'] = df['home_team'].replace(repl)
|
17
|
+
## add extra checks to make comparable with pbp ##
|
18
|
+
for col in [
|
19
|
+
'posteam', 'defteam', 'penalty_team',
|
20
|
+
'side_of_field', 'timeout_team', 'td_team',
|
21
|
+
'return_team'
|
22
|
+
]:
|
23
|
+
if col in df.columns:
|
24
|
+
df[col] = df[col].replace(repl)
|
25
|
+
## id col ##
|
17
26
|
df['game_id'] = (
|
18
27
|
df['season'].astype('str') + '_' +
|
19
28
|
df['week'].astype('str').str.zfill(2) + '_' +
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import pandas as pd
|
2
|
+
import numpy
|
3
|
+
|
4
|
+
def penalty_formatting(df):
|
5
|
+
"""
|
6
|
+
Adds additional context to penalties
|
7
|
+
"""
|
8
|
+
## offensive and defensive penalties ##
|
9
|
+
df['off_penalty'] = numpy.where(
|
10
|
+
df['penalty_team'] == df['posteam'],
|
11
|
+
1,
|
12
|
+
0
|
13
|
+
)
|
14
|
+
df['def_penalty'] = numpy.where(
|
15
|
+
df['penalty_team'] == df['defteam'],
|
16
|
+
1,
|
17
|
+
0
|
18
|
+
)
|
19
|
+
## remove nans from penalties to enable groupings ##
|
20
|
+
df['penalty_type'] = df['penalty_type'].fillna('No Penalty')
|
21
|
+
return df
|
nfelodcm/nfelodcm/Maps/pbp.json
CHANGED
nfelodcm/nfelodcm/nfelodcm.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import pandas as pd
|
2
2
|
import numpy
|
3
|
+
import pathlib
|
4
|
+
import json
|
3
5
|
|
4
6
|
from .Engine import DCMTable
|
5
7
|
import nfelodcm.nfelodcm.Utilities as utils
|
@@ -46,4 +48,23 @@ def get_map(url):
|
|
46
48
|
print('"{0}": "{1}",'.format(
|
47
49
|
col, dtype
|
48
50
|
))
|
49
|
-
|
51
|
+
|
52
|
+
def get_season_state(state_type='last_full_week'):
|
53
|
+
'''
|
54
|
+
Returns the season and week of the specified state type:
|
55
|
+
'last_full_week' (default): the last week in which no games are still unplayed
|
56
|
+
'last_partual_week': the last week where any game has been played
|
57
|
+
'next_week': the first week with no games played
|
58
|
+
'''
|
59
|
+
## open global variables json ##
|
60
|
+
global_variables = None
|
61
|
+
with open('{0}/global_variables.json'.format(pathlib.Path(__file__).parent.resolve()), 'r') as fp:
|
62
|
+
## load config ##
|
63
|
+
global_variables = json.load(fp)
|
64
|
+
## check input ##
|
65
|
+
if state_type not in list(global_variables['season_states'].keys()):
|
66
|
+
raise Exception('UTILITY ERROR: {0} is not an available state_type. Available types: {1}'.format(
|
67
|
+
state_type, '\n '.join(list(global_variables['season_states'].keys()))
|
68
|
+
))
|
69
|
+
## if state valid, return ##
|
70
|
+
return global_variables[state_type]['season'], global_variables[state_type]['week']
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: nfelodcm
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.7
|
4
4
|
Summary: Python package for loading and caching CSVs hosted on github into pandas dataframes
|
5
5
|
Author-email: Robert Greer <nfl@robbygreer.com>
|
6
6
|
Maintainer-email: Robert Greer <nfl@robbygreer.com>
|
@@ -1,11 +1,13 @@
|
|
1
1
|
nfelodcm/__init__.py,sha256=T4OUcbJYVwMLzKSrm7CRT84jeqlvQeVWhfV2RCKlYM0,112
|
2
|
-
nfelodcm/nfelodcm/nfelodcm.py,sha256=
|
2
|
+
nfelodcm/nfelodcm/nfelodcm.py,sha256=97BA_U3RikyzxS5Mbewrgb4HYYTa1YQ4S47l5wN_tA0,2145
|
3
3
|
nfelodcm/nfelodcm/Engine/DCMTable.py,sha256=9_x82HKPWOwkIqQF4qZvUCLg8n6IUQfrtLlaU4bPIxM,2646
|
4
4
|
nfelodcm/nfelodcm/Engine/__init__.py,sha256=vEEWcIBE4KLHoBCT1s2AIeSZxMfv1bcAqUNAJzSMSMo,31
|
5
5
|
nfelodcm/nfelodcm/Engine/Assignments/__init__.py,sha256=IPKxTBbO3b0xaO922zkwif0FFd8Xqe3ZvCIFjhYg1oE,80
|
6
|
-
nfelodcm/nfelodcm/Engine/Assignments/assignment.py,sha256=
|
7
|
-
nfelodcm/nfelodcm/Engine/Assignments/assignments/__init__.py,sha256=
|
8
|
-
nfelodcm/nfelodcm/Engine/Assignments/assignments/
|
6
|
+
nfelodcm/nfelodcm/Engine/Assignments/assignment.py,sha256=Mol-Sc5buLfJ-h9ItzeUxXxPAzvj0rvQbUJhl3_lgL4,1191
|
7
|
+
nfelodcm/nfelodcm/Engine/Assignments/assignments/__init__.py,sha256=9dMIp6FZu3ZrvTHomWqkzF77em8P9hxKhuXl-lIyRQ4,139
|
8
|
+
nfelodcm/nfelodcm/Engine/Assignments/assignments/desc_based_plays.py,sha256=LAXOlE-IW8A49rRagxcAGRao_4c2RdC7AK6_iV3M2Vc,1810
|
9
|
+
nfelodcm/nfelodcm/Engine/Assignments/assignments/fastr_team_repl.py,sha256=YD3ci5BsuEelFEuyRyUbAqSuAiBeIFsMuhTvXbvg6Ik,865
|
10
|
+
nfelodcm/nfelodcm/Engine/Assignments/assignments/penalty_formatting.py,sha256=Ia3x_Z8EnzI4Bz_6LEfY0ICWvdmyzJsckrOUXGYgfRY,517
|
9
11
|
nfelodcm/nfelodcm/Engine/Primatives/DataPull.py,sha256=x1SUfCpxbXr923o52ExLMJItVKujSfcBeJDrDkFop70,2909
|
10
12
|
nfelodcm/nfelodcm/Engine/Primatives/Freshness.py,sha256=5dGPoFCeCBdhvr5g_Ey-xAK742F596uQfwBEfDouj7U,9679
|
11
13
|
nfelodcm/nfelodcm/Engine/Primatives/LocalIO.py,sha256=aVdPiz-gkyrJLPOHBg87PiNWZAI6EZGfyJVej9Z2uk0,1527
|
@@ -14,7 +16,7 @@ nfelodcm/nfelodcm/Engine/Primatives/__init__.py,sha256=JUHF_8_1vqbp7M5rJfDwzqkgi
|
|
14
16
|
nfelodcm/nfelodcm/Maps/games.json,sha256=TPEsWetmMBhmSWkCkSfgWqv1R1X9FkNIdDnWs_nqzGw,1829
|
15
17
|
nfelodcm/nfelodcm/Maps/logos.json,sha256=7RLhXIp9bvp6EwALrwccCiY1_iNizYVV7M2XEwDRb5E,1776
|
16
18
|
nfelodcm/nfelodcm/Maps/participants.json,sha256=Q0eeE0qbp91pIwjlH9WM7wI8n2gbwgywm-vRAkw1ofA,1211
|
17
|
-
nfelodcm/nfelodcm/Maps/pbp.json,sha256
|
19
|
+
nfelodcm/nfelodcm/Maps/pbp.json,sha256=tU_Zhwju3iD7bju_4DnCJuUxXofkI-9jIe-zDQgylLU,10425
|
18
20
|
nfelodcm/nfelodcm/Maps/qbelo.json,sha256=owSpd3hlC58HLCAeeTAhpIzhx9lA6EuvPfTlETklOpU,1832
|
19
21
|
nfelodcm/nfelodcm/Maps/qbr.json,sha256=8zewIU0ted9FNFkjwyM308sR_pGvoB0PzZDeZhQUKXg,1153
|
20
22
|
nfelodcm/nfelodcm/Maps/rosters.json,sha256=RvinVFIOSuBGeDwp3XqhKFeaWH8-A_nQRUO4KEM7JZ8,1435
|
@@ -24,7 +26,7 @@ nfelodcm/nfelodcm/Utilities/extract_map.py,sha256=DVITMr0mlP6p2V1ZdaIcbEavs-FZ28
|
|
24
26
|
nfelodcm/nfelodcm/Utilities/global_variables.json,sha256=FrKTTJ3VJRTV8RdQmjpXZzIPLLC594SpiMBR6xYs7Nw,299
|
25
27
|
nfelodcm/nfelodcm/Utilities/retrieve_season_state.py,sha256=ZrBaMWmo2DA9OZqZ6MBWmrY9Llkc5OUfxmDk7EB1tRU,579
|
26
28
|
nfelodcm/nfelodcm/Utilities/set_season_state.py,sha256=Y5fvop3EZfWcx2F85MtSNEGnwjofWyEMg4_HLTenAUA,3737
|
27
|
-
nfelodcm-0.1.
|
28
|
-
nfelodcm-0.1.
|
29
|
-
nfelodcm-0.1.
|
30
|
-
nfelodcm-0.1.
|
29
|
+
nfelodcm-0.1.7.dist-info/METADATA,sha256=i33HF_CTQxLPayZsoNav3yyeHWywSuKmQHioMSBgIus,4409
|
30
|
+
nfelodcm-0.1.7.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
|
31
|
+
nfelodcm-0.1.7.dist-info/top_level.txt,sha256=SlNA7_yZSwWvZIl9Md6brBH_C7nAYnATe4CrvuUXOGo,9
|
32
|
+
nfelodcm-0.1.7.dist-info/RECORD,,
|
File without changes
|