nfelodcm 0.1.4__tar.gz → 0.1.7__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 (38) hide show
  1. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/PKG-INFO +1 -1
  2. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Engine/Assignments/assignment.py +15 -1
  3. nfelodcm-0.1.7/nfelodcm/Engine/Assignments/assignments/__init__.py +3 -0
  4. nfelodcm-0.1.7/nfelodcm/Engine/Assignments/assignments/desc_based_plays.py +57 -0
  5. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Engine/Assignments/assignments/fastr_team_repl.py +9 -0
  6. nfelodcm-0.1.7/nfelodcm/Engine/Assignments/assignments/penalty_formatting.py +21 -0
  7. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Maps/pbp.json +3 -1
  8. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/nfelodcm.py +22 -1
  9. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm.egg-info/PKG-INFO +1 -1
  10. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm.egg-info/SOURCES.txt +2 -0
  11. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/pyproject.toml +1 -1
  12. nfelodcm-0.1.4/nfelodcm/Engine/Assignments/assignments/__init__.py +0 -1
  13. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/README.md +0 -0
  14. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/__init__.py +0 -0
  15. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Engine/Assignments/__init__.py +0 -0
  16. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Engine/DCMTable.py +0 -0
  17. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Engine/Primatives/DataPull.py +0 -0
  18. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Engine/Primatives/Freshness.py +0 -0
  19. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Engine/Primatives/LocalIO.py +0 -0
  20. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Engine/Primatives/TableMap.py +0 -0
  21. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Engine/Primatives/__init__.py +0 -0
  22. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Engine/__init__.py +0 -0
  23. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Maps/games.json +0 -0
  24. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Maps/logos.json +0 -0
  25. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Maps/participants.json +0 -0
  26. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Maps/qbelo.json +0 -0
  27. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Maps/qbr.json +0 -0
  28. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Maps/rosters.json +0 -0
  29. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Utilities/__init__.py +0 -0
  30. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Utilities/checks.py +0 -0
  31. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Utilities/extract_map.py +0 -0
  32. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Utilities/global_variables.json +0 -0
  33. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Utilities/retrieve_season_state.py +0 -0
  34. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm/Utilities/set_season_state.py +0 -0
  35. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm.egg-info/dependency_links.txt +0 -0
  36. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm.egg-info/requires.txt +0 -0
  37. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/nfelodcm.egg-info/top_level.txt +0 -0
  38. {nfelodcm-0.1.4 → nfelodcm-0.1.7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nfelodcm
3
- Version: 0.1.4
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,10 +1,24 @@
1
- from .assignments import game_id_repl
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,3 @@
1
+ from .fastr_team_repl import game_id_repl
2
+ from .penalty_formatting import penalty_formatting
3
+ from .desc_based_plays import desc_based_plays
@@ -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
@@ -16,7 +16,9 @@
16
16
  "type": "season",
17
17
  "start": 1999
18
18
  },
19
- "assignments": [],
19
+ "assignments": [
20
+ "game_id_repl", "penalty_formatting", "desc_based_plays"
21
+ ],
20
22
  "map": {
21
23
  "play_id": "int32",
22
24
  "game_id": "object",
@@ -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.4
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>
@@ -7,7 +7,9 @@ pyproject.toml
7
7
  ./nfelodcm/Engine/Assignments/__init__.py
8
8
  ./nfelodcm/Engine/Assignments/assignment.py
9
9
  ./nfelodcm/Engine/Assignments/assignments/__init__.py
10
+ ./nfelodcm/Engine/Assignments/assignments/desc_based_plays.py
10
11
  ./nfelodcm/Engine/Assignments/assignments/fastr_team_repl.py
12
+ ./nfelodcm/Engine/Assignments/assignments/penalty_formatting.py
11
13
  ./nfelodcm/Engine/Primatives/DataPull.py
12
14
  ./nfelodcm/Engine/Primatives/Freshness.py
13
15
  ./nfelodcm/Engine/Primatives/LocalIO.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "nfelodcm"
7
- version = "0.1.4"
7
+ version = "0.1.7"
8
8
  readme = "README.md"
9
9
  requires-python = ">=3.11"
10
10
  license = {text = "MIT"}
@@ -1 +0,0 @@
1
- from .fastr_team_repl import game_id_repl
File without changes
File without changes
File without changes