nfelodcm 0.1.5__tar.gz → 0.1.8__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 (48) hide show
  1. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/PKG-INFO +1 -1
  2. nfelodcm-0.1.8/__init__.py +5 -0
  3. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Engine/Assignments/assignment.py +6 -5
  4. nfelodcm-0.1.8/nfelodcm/Engine/Assignments/assignments/__init__.py +3 -0
  5. nfelodcm-0.1.8/nfelodcm/Engine/Assignments/assignments/fastr_team_repl.py +34 -0
  6. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Engine/DCMTable.py +6 -0
  7. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Engine/Primatives/Freshness.py +2 -0
  8. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Engine/Primatives/LocalIO.py +37 -0
  9. nfelodcm-0.1.8/nfelodcm/Maps/filmmargins.json +34 -0
  10. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Maps/games.json +3 -3
  11. nfelodcm-0.1.8/nfelodcm/Maps/logos.json +40 -0
  12. nfelodcm-0.1.8/nfelodcm/Maps/market_data.json +60 -0
  13. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Maps/participants.json +8 -5
  14. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Maps/pbp.json +5 -3
  15. nfelodcm-0.1.8/nfelodcm/Maps/player_stats.json +77 -0
  16. nfelodcm-0.1.8/nfelodcm/Maps/players.json +57 -0
  17. nfelodcm-0.1.8/nfelodcm/Maps/qbelo.json +55 -0
  18. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Maps/qbr.json +2 -2
  19. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Maps/rosters.json +2 -2
  20. nfelodcm-0.1.8/nfelodcm/Maps/wepa.json +40 -0
  21. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Utilities/global_variables.json +4 -4
  22. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/nfelodcm.py +22 -1
  23. nfelodcm-0.1.8/nfelodcm/tests.py +38 -0
  24. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm.egg-info/PKG-INFO +1 -1
  25. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm.egg-info/SOURCES.txt +6 -0
  26. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/pyproject.toml +1 -1
  27. nfelodcm-0.1.5/__init__.py +0 -3
  28. nfelodcm-0.1.5/nfelodcm/Engine/Assignments/assignments/__init__.py +0 -3
  29. nfelodcm-0.1.5/nfelodcm/Engine/Assignments/assignments/fastr_team_repl.py +0 -32
  30. nfelodcm-0.1.5/nfelodcm/Maps/logos.json +0 -70
  31. nfelodcm-0.1.5/nfelodcm/Maps/qbelo.json +0 -70
  32. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/README.md +0 -0
  33. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Engine/Assignments/__init__.py +0 -0
  34. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Engine/Assignments/assignments/desc_based_plays.py +0 -0
  35. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Engine/Assignments/assignments/penalty_formatting.py +0 -0
  36. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Engine/Primatives/DataPull.py +0 -0
  37. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Engine/Primatives/TableMap.py +0 -0
  38. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Engine/Primatives/__init__.py +0 -0
  39. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Engine/__init__.py +0 -0
  40. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Utilities/__init__.py +0 -0
  41. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Utilities/checks.py +0 -0
  42. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Utilities/extract_map.py +0 -0
  43. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Utilities/retrieve_season_state.py +0 -0
  44. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm/Utilities/set_season_state.py +0 -0
  45. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm.egg-info/dependency_links.txt +0 -0
  46. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm.egg-info/requires.txt +0 -0
  47. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/nfelodcm.egg-info/top_level.txt +0 -0
  48. {nfelodcm-0.1.5 → nfelodcm-0.1.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nfelodcm
3
- Version: 0.1.5
3
+ Version: 0.1.8
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>
@@ -0,0 +1,5 @@
1
+ from .nfelodcm.nfelodcm import get_df
2
+ from .nfelodcm.nfelodcm import load
3
+ from .nfelodcm.nfelodcm import get_map
4
+ from .nfelodcm.nfelodcm import get_season_state
5
+ from .nfelodcm.tests import test_all_maps
@@ -1,11 +1,11 @@
1
1
  from .assignments import (
2
- game_id_repl, penalty_formatting, desc_based_plays
2
+ fastr_team_id_repl, penalty_formatting, desc_based_plays
3
3
  )
4
4
 
5
5
  ## a dictionary that holds assignments and the columns they add ##
6
6
  assignments = {
7
- 'game_id_repl' : {
8
- 'func' : game_id_repl,
7
+ 'fastr_team_id_repl' : {
8
+ 'func' : fastr_team_id_repl,
9
9
  'new_columns' : []
10
10
  },
11
11
  'penalty_formatting' : {
@@ -15,8 +15,9 @@ assignments = {
15
15
  'desc_based_plays' : {
16
16
  'func' : desc_based_plays,
17
17
  'new_columns' : [
18
- 'qb_dropback_all', 'rush_attempt_all',
19
- 'play_call'
18
+ ('qb_dropback_all', 'float32'),
19
+ ('rush_attempt_all', 'float32'),
20
+ ('play_call', 'str'),
20
21
  ]
21
22
  }
22
23
  }
@@ -0,0 +1,3 @@
1
+ from .fastr_team_repl import team_id_repl as fastr_team_id_repl
2
+ from .penalty_formatting import penalty_formatting
3
+ from .desc_based_plays import desc_based_plays
@@ -0,0 +1,34 @@
1
+ import pandas as pd
2
+
3
+ ## assignment functions that replaces fastr team names with legacy team names ##
4
+ repl = {
5
+ 'LV' : 'OAK',
6
+ 'SD' : 'LAC',
7
+ 'STL' : 'LAR',
8
+ 'LA' : 'LAR',
9
+ }
10
+
11
+ def team_id_repl(df):
12
+ """
13
+ Replaces fastr team ids with a legacy nfelo ids.
14
+ """
15
+ ## if a col with team names exists, replace it ##
16
+ for col in [
17
+ 'home_team', 'away_team', 'team_abbr',
18
+ 'posteam', 'defteam', 'penalty_team',
19
+ 'side_of_field', 'timeout_team', 'td_team',
20
+ 'return_team', 'possession_team',
21
+ 'recent_team', 'opponent_team'
22
+ ]:
23
+ if col in df.columns:
24
+ df[col] = df[col].replace(repl)
25
+ ## if game if is also in the DF, replace it
26
+ if 'game_id' in df.columns:
27
+ ## id col ##
28
+ df['game_id'] = (
29
+ df['season'].astype('str') + '_' +
30
+ df['week'].astype('str').str.zfill(2) + '_' +
31
+ df['away_team'] + '_' +
32
+ df['home_team']
33
+ )
34
+ return df
@@ -49,6 +49,12 @@ class DCMTable():
49
49
  """
50
50
  Handles loading of the table based on freshness status.
51
51
  """
52
+ ## add a check to always make sure there is a local file in the DB.
53
+ ## If a CSV is deleted or a write fails, timestamps, and therefore
54
+ ## freshness, may incorrectly assume we have a current file to read
55
+ if not self.localIO.loadable():
56
+ ## if the csv does not exist, flag the update flag ##
57
+ self.freshness.needs_update=True
52
58
  if self.freshness.freshness_check_time is not None:
53
59
  ## if freshness was checked, update the time in the config ##
54
60
  self.tableMap.config['freshness']['last_freshness_check'] = self.freshness.freshness_check_time
@@ -159,6 +159,8 @@ class Freshness():
159
159
  ## handle response ##
160
160
  if r.status_code != 200:
161
161
  print('WARN: Request to github commits failed.')
162
+ print(' Returned {0}'.format(r.status_code))
163
+ print(' Msg: {0}'.format(r.content))
162
164
  return
163
165
  r = r.json()
164
166
  if len(r) == 0:
@@ -1,4 +1,5 @@
1
1
  import pandas as pd
2
+ import os
2
3
  import numpy
3
4
  import json
4
5
 
@@ -28,10 +29,46 @@ class LocalIO():
28
29
  self.columns.append(col[0])
29
30
  self.dtypes[col[0]] = col[1]
30
31
 
32
+ def local_exists(self):
33
+ """
34
+ Checks to make sure their is a local CSV at the filepath
35
+ """
36
+ return os.path.exists(self.data_location)
37
+
38
+ def cols_pass(self):
39
+ """
40
+ Checks the local file for columns and matches to
41
+ cols int eh config
42
+ """
43
+ ## parse config cols ##
44
+ config_cols = list(self.config['map'].keys())
45
+ ## parse local cols ##
46
+ local_cols = []
47
+ if self.local_exists():
48
+ ## if local file exists, load the first line ##
49
+ local_cols = pd.read_csv(self.data_location, nrows=1).columns.tolist()
50
+ ## make comparison ##
51
+ for col in config_cols:
52
+ if col not in local_cols:
53
+ return False
54
+ ## if all passed, return true ##
55
+ return True
56
+
57
+
58
+ def loadable(self):
59
+ """
60
+ Runs multiple checks to make sure the file can be read
61
+ by the config
62
+ """
63
+ return self.local_exists() and self.cols_pass()
64
+
31
65
  def read(self):
32
66
  """
33
67
  Read the data from local CSV
34
68
  """
69
+ ## check that path exists first ##
70
+ if not self.loadable():
71
+ raise Exception('IO ERROR: Attempting read a local CSV that does not exist')
35
72
  self.df = pd.read_csv(
36
73
  self.data_location,
37
74
  usecols=self.columns,
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "filmmargins",
3
+ "description": "Margins derived from PFF grades",
4
+ "last_local_update": "2024-07-07T23:35:11.485380",
5
+ "download_url": "https://raw.githubusercontent.com/greerreNFL/filmmargin/main/film_margins.csv",
6
+ "compression": null,
7
+ "engine": "c",
8
+ "freshness": {
9
+ "type": "gh_commit",
10
+ "gh_api_endpoint": "https://api.github.com/repos/greerreNFL/filmmargin/commits?path=film_margins.csv",
11
+ "gh_release_tag": null,
12
+ "sla_seconds": 900,
13
+ "last_freshness_check": "2024-07-10T17:15:32.031946+00:00"
14
+ },
15
+ "iter": {
16
+ "type": null,
17
+ "start": null
18
+ },
19
+ "assignments": [],
20
+ "map": {
21
+ "Unnamed: 0": "int32",
22
+ "game_id": "object",
23
+ "season": "int32",
24
+ "week": "int32",
25
+ "team": "object",
26
+ "opponent": "object",
27
+ "pf": "int32",
28
+ "pa": "int32",
29
+ "margin": "int32",
30
+ "film_margin": "float32",
31
+ "film_margin_predictive": "float32",
32
+ "film_margin_old_model": "float32"
33
+ }
34
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "games",
3
3
  "description": "nflgamedata games",
4
- "last_local_update": "2023-12-31T04:51:21.399721",
4
+ "last_local_update": "2024-07-07T23:13:58.469798",
5
5
  "download_url": "https://raw.githubusercontent.com/nflverse/nfldata/master/data/games.csv",
6
6
  "compression": null,
7
7
  "engine": "c",
@@ -10,14 +10,14 @@
10
10
  "gh_api_endpoint": "https://api.github.com/repos/nflverse/nfldata/commits",
11
11
  "gh_release_tag": null,
12
12
  "sla_seconds": 500,
13
- "last_freshness_check": "2023-12-31T05:27:06.725310+00:00"
13
+ "last_freshness_check": "2024-07-10T17:15:31.355055+00:00"
14
14
  },
15
15
  "iter": {
16
16
  "type": null,
17
17
  "start": null
18
18
  },
19
19
  "assignments": [
20
- "game_id_repl"
20
+ "fastr_team_id_repl"
21
21
  ],
22
22
  "map": {
23
23
  "game_id": "object",
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "logos",
3
+ "description": "nflfastr logos",
4
+ "last_local_update": "2024-07-07T23:35:10.755659",
5
+ "download_url": "https://raw.githubusercontent.com/nflverse/nflverse-pbp/master/teams_colors_logos.csv",
6
+ "compression": null,
7
+ "engine": "c",
8
+ "freshness": {
9
+ "type": "gh_commit",
10
+ "gh_api_endpoint": "https://api.github.com/repos/nflverse/nflverse-pbp/commits?path=teams_colors_logos.csv",
11
+ "gh_release_tag": null,
12
+ "sla_seconds": 900,
13
+ "last_freshness_check": "2024-07-10T17:15:31.722504+00:00"
14
+ },
15
+ "iter": {
16
+ "type": null,
17
+ "start": null
18
+ },
19
+ "assignments": [
20
+ "fastr_team_id_repl"
21
+ ],
22
+ "map": {
23
+ "team_abbr": "object",
24
+ "team_name": "object",
25
+ "team_id": "int32",
26
+ "team_nick": "object",
27
+ "team_conf": "object",
28
+ "team_division": "object",
29
+ "team_color": "object",
30
+ "team_color2": "object",
31
+ "team_color3": "object",
32
+ "team_color4": "object",
33
+ "team_logo_wikipedia": "object",
34
+ "team_logo_espn": "object",
35
+ "team_wordmark": "object",
36
+ "team_conference_logo": "object",
37
+ "team_league_logo": "object",
38
+ "team_logo_squared": "object"
39
+ }
40
+ }
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "market_data",
3
+ "description": "Spread and totals from various sources",
4
+ "last_local_update": "2024-07-08T03:34:47.332681",
5
+ "download_url": "https://raw.githubusercontent.com/greerreNFL/nfelomarket_data/main/Data/lines.csv",
6
+ "compression": null,
7
+ "engine": "c",
8
+ "freshness": {
9
+ "type": "gh_commit",
10
+ "gh_api_endpoint": "https://api.github.com/repos/greerreNFL/nfelomarket_data/commits?path=Data/lines.csv",
11
+ "gh_release_tag": null,
12
+ "sla_seconds": 900,
13
+ "last_freshness_check": "2024-07-10T17:16:07.623265+00:00"
14
+ },
15
+ "iter": {
16
+ "type": null,
17
+ "start": null
18
+ },
19
+ "assignments": [],
20
+ "map": {
21
+ "Unnamed: 0": "int32",
22
+ "game_id": "object",
23
+ "season": "int32",
24
+ "week": "int32",
25
+ "home_team": "object",
26
+ "away_team": "object",
27
+ "home_spread_open": "float32",
28
+ "home_spread_open_price": "float32",
29
+ "away_spread_open_price": "float32",
30
+ "home_spread_open_source": "object",
31
+ "home_spread_open_timestamp": "object",
32
+ "home_spread_last": "float32",
33
+ "home_spread_last_price": "float32",
34
+ "away_spread_last_price": "float32",
35
+ "home_spread_last_source": "object",
36
+ "home_spread_last_timestamp": "object",
37
+ "home_spread_tickets_pct": "float32",
38
+ "home_spread_money_pct": "float32",
39
+ "home_spread_pcts_source": "object",
40
+ "home_spread_pct_timestamp": "object",
41
+ "home_ml_open": "float32",
42
+ "away_ml_open": "float32",
43
+ "ml_open_source": "object",
44
+ "ml_open_timestamp": "object",
45
+ "home_ml_last": "float32",
46
+ "away_ml_last": "float32",
47
+ "ml_last_source": "object",
48
+ "ml_last_timestamp": "object",
49
+ "total_line_open": "float32",
50
+ "under_price_open": "float32",
51
+ "over_price_open": "float32",
52
+ "total_line_open_source": "object",
53
+ "total_line_open_timestamp": "object",
54
+ "total_line_last": "float32",
55
+ "under_price_last": "float32",
56
+ "over_price_last": "float32",
57
+ "total_line_last_source": "object",
58
+ "total_line_last_timestamp": "object"
59
+ }
60
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "participants",
3
3
  "description": "nflfastR participants",
4
- "last_local_update": null,
4
+ "last_local_update": "2024-07-10T17:16:25.862176",
5
5
  "download_url": "https://github.com/nflverse/nflverse-data/releases/download/pbp_participation/pbp_participation_{0}.csv",
6
6
  "compression": null,
7
7
  "engine": "c",
@@ -10,14 +10,17 @@
10
10
  "gh_api_endpoint": "https://api.github.com/repos/nflverse/nflverse-data/releases/tags",
11
11
  "gh_release_tag": "pbp_participation",
12
12
  "sla_seconds": 900,
13
- "last_freshness_check": null
13
+ "last_freshness_check": "2024-07-10T17:16:08.727121+00:00"
14
14
  },
15
15
  "iter": {
16
16
  "type": "season",
17
17
  "start": 2016
18
18
  },
19
- "assignments": [],
19
+ "assignments": [
20
+ "fastr_team_id_repl"
21
+ ],
20
22
  "map": {
23
+ "nflverse_game_id": "object",
21
24
  "old_game_id": "int32",
22
25
  "play_id": "int32",
23
26
  "possession_team": "object",
@@ -35,7 +38,7 @@
35
38
  "time_to_throw": "float32",
36
39
  "was_pressure": "object",
37
40
  "route": "object",
38
- "defense_man_zone_type": "float32",
39
- "defense_coverage_type": "float32"
41
+ "defense_man_zone_type": "object",
42
+ "defense_coverage_type": "object"
40
43
  }
41
44
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pbp",
3
3
  "description": "nflfastR play-by-play",
4
- "last_local_update": "2023-12-28T05:48:27.222659",
4
+ "last_local_update": "2024-07-07T23:37:14.767747",
5
5
  "download_url": "https://github.com/nflverse/nflverse-data/releases/download/pbp/play_by_play_{0}.csv.gz",
6
6
  "compression": "gzip",
7
7
  "engine": "c",
@@ -10,14 +10,16 @@
10
10
  "gh_api_endpoint": "https://api.github.com/repos/nflverse/nflverse-data/releases/tags",
11
11
  "gh_release_tag": "pbp",
12
12
  "sla_seconds": 900,
13
- "last_freshness_check": "2023-12-28T05:46:15.982851+00:00"
13
+ "last_freshness_check": "2024-07-10T17:15:32.328227+00:00"
14
14
  },
15
15
  "iter": {
16
16
  "type": "season",
17
17
  "start": 1999
18
18
  },
19
19
  "assignments": [
20
- "game_id_repl", "penalty_formatting", "desc_based_plays"
20
+ "fastr_team_id_repl",
21
+ "penalty_formatting",
22
+ "desc_based_plays"
21
23
  ],
22
24
  "map": {
23
25
  "play_id": "int32",
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "player_stats",
3
+ "description": "nflfastR player stats",
4
+ "last_local_update": "2024-07-07T23:37:18.361644",
5
+ "download_url": "https://github.com/nflverse/nflverse-data/releases/download/player_stats/player_stats.csv.gz",
6
+ "compression": "gzip",
7
+ "engine": "c",
8
+ "freshness": {
9
+ "type": "gh_release",
10
+ "gh_api_endpoint": "https://api.github.com/repos/nflverse/nflverse-data/releases/tags",
11
+ "gh_release_tag": "player_stats",
12
+ "sla_seconds": 900,
13
+ "last_freshness_check": "2024-07-10T17:16:05.954026+00:00"
14
+ },
15
+ "iter": {
16
+ "type": null,
17
+ "start": null
18
+ },
19
+ "assignments": [
20
+ "fastr_team_id_repl"
21
+ ],
22
+ "map": {
23
+ "player_id": "object",
24
+ "player_name": "object",
25
+ "player_display_name": "object",
26
+ "position": "object",
27
+ "position_group": "object",
28
+ "headshot_url": "object",
29
+ "recent_team": "object",
30
+ "season": "int32",
31
+ "week": "int32",
32
+ "season_type": "object",
33
+ "opponent_team": "object",
34
+ "completions": "int32",
35
+ "attempts": "int32",
36
+ "passing_yards": "int32",
37
+ "passing_tds": "int32",
38
+ "interceptions": "int32",
39
+ "sacks": "int32",
40
+ "sack_yards": "int32",
41
+ "sack_fumbles": "int32",
42
+ "sack_fumbles_lost": "int32",
43
+ "passing_air_yards": "int32",
44
+ "passing_yards_after_catch": "int32",
45
+ "passing_first_downs": "int32",
46
+ "passing_epa": "float32",
47
+ "passing_2pt_conversions": "int32",
48
+ "pacr": "float32",
49
+ "dakota": "float32",
50
+ "carries": "int32",
51
+ "rushing_yards": "int32",
52
+ "rushing_tds": "int32",
53
+ "rushing_fumbles": "int32",
54
+ "rushing_fumbles_lost": "int32",
55
+ "rushing_first_downs": "int32",
56
+ "rushing_epa": "float32",
57
+ "rushing_2pt_conversions": "int32",
58
+ "receptions": "int32",
59
+ "targets": "int32",
60
+ "receiving_yards": "int32",
61
+ "receiving_tds": "int32",
62
+ "receiving_fumbles": "int32",
63
+ "receiving_fumbles_lost": "int32",
64
+ "receiving_air_yards": "int32",
65
+ "receiving_yards_after_catch": "int32",
66
+ "receiving_first_downs": "int32",
67
+ "receiving_epa": "float32",
68
+ "receiving_2pt_conversions": "int32",
69
+ "racr": "float32",
70
+ "target_share": "float32",
71
+ "air_yards_share": "float32",
72
+ "wopr": "float32",
73
+ "special_teams_tds": "int32",
74
+ "fantasy_points": "float32",
75
+ "fantasy_points_ppr": "float32"
76
+ }
77
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "players",
3
+ "description": "nflfastR player meta data",
4
+ "last_local_update": "2024-07-10T17:16:29.561868",
5
+ "download_url": "https://github.com/nflverse/nflverse-data/releases/download/players/players.csv",
6
+ "compression": null,
7
+ "engine": "c",
8
+ "freshness": {
9
+ "type": "gh_release",
10
+ "gh_api_endpoint": "https://api.github.com/repos/nflverse/nflverse-data/releases/tags",
11
+ "gh_release_tag": "players",
12
+ "sla_seconds": 900,
13
+ "last_freshness_check": "2024-07-10T17:16:27.390522+00:00"
14
+ },
15
+ "iter": {
16
+ "type": null,
17
+ "start": null
18
+ },
19
+ "assignments": [
20
+ "fastr_team_id_repl"
21
+ ],
22
+ "map": {
23
+ "status": "object",
24
+ "display_name": "object",
25
+ "first_name": "object",
26
+ "last_name": "object",
27
+ "esb_id": "object",
28
+ "gsis_id": "object",
29
+ "birth_date": "object",
30
+ "college_name": "object",
31
+ "position_group": "object",
32
+ "position": "object",
33
+ "jersey_number": "float32",
34
+ "height": "float32",
35
+ "weight": "float32",
36
+ "years_of_experience": "float32",
37
+ "team_abbr": "object",
38
+ "team_seq": "float32",
39
+ "current_team_id": "float32",
40
+ "football_name": "object",
41
+ "entry_year": "float32",
42
+ "rookie_year": "float32",
43
+ "draft_club": "object",
44
+ "draft_number": "float32",
45
+ "college_conference": "object",
46
+ "status_description_abbr": "object",
47
+ "status_short_description": "object",
48
+ "gsis_it_id": "float32",
49
+ "short_name": "object",
50
+ "smart_id": "object",
51
+ "headshot": "object",
52
+ "suffix": "object",
53
+ "uniform_number": "object",
54
+ "draft_round": "float32",
55
+ "season": "float32"
56
+ }
57
+ }
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "qbelo",
3
+ "description": "538/nfelo QB Elo model",
4
+ "last_local_update": "2024-07-08T03:34:46.537617",
5
+ "download_url": "https://raw.githubusercontent.com/greerreNFL/nfeloqb/main/qb_elos.csv",
6
+ "compression": null,
7
+ "engine": "c",
8
+ "freshness": {
9
+ "type": "gh_commit",
10
+ "gh_api_endpoint": "https://api.github.com/repos/greerreNFL/nfeloqb/commits?path=qb_elos.csv",
11
+ "gh_release_tag": null,
12
+ "sla_seconds": 900,
13
+ "last_freshness_check": "2024-07-10T17:16:07.189582+00:00"
14
+ },
15
+ "iter": {
16
+ "type": null,
17
+ "start": null
18
+ },
19
+ "assignments": [],
20
+ "map": {
21
+ "date": "object",
22
+ "season": "int32",
23
+ "neutral": "int32",
24
+ "playoff": "object",
25
+ "team1": "object",
26
+ "team2": "object",
27
+ "elo1_pre": "float32",
28
+ "elo2_pre": "float32",
29
+ "elo_prob1": "float32",
30
+ "elo_prob2": "float32",
31
+ "elo1_post": "float32",
32
+ "elo2_post": "float32",
33
+ "qbelo1_pre": "float32",
34
+ "qbelo2_pre": "float32",
35
+ "qb1": "object",
36
+ "qb2": "object",
37
+ "qb1_value_pre": "float32",
38
+ "qb2_value_pre": "float32",
39
+ "qb1_adj": "float32",
40
+ "qb2_adj": "float32",
41
+ "qbelo_prob1": "float32",
42
+ "qbelo_prob2": "float32",
43
+ "qb1_game_value": "float32",
44
+ "qb2_game_value": "float32",
45
+ "qb1_value_post": "float32",
46
+ "qb2_value_post": "float32",
47
+ "qbelo1_post": "float32",
48
+ "qbelo2_post": "float32",
49
+ "score1": "float32",
50
+ "score2": "float32",
51
+ "quality": "float32",
52
+ "importance": "float32",
53
+ "total_rating": "float32"
54
+ }
55
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "qbr",
3
3
  "description": "nflverse QBR",
4
- "last_local_update": null,
4
+ "last_local_update": "2024-07-07T23:13:57.437639",
5
5
  "download_url": "https://github.com/nflverse/nflverse-data/releases/download/espn_data/qbr_season_level.csv",
6
6
  "compression": null,
7
7
  "engine": "c",
@@ -10,7 +10,7 @@
10
10
  "gh_api_endpoint": "https://api.github.com/repos/nflverse/nflverse-data/releases/tags",
11
11
  "gh_release_tag": "espn_data",
12
12
  "sla_seconds": 900,
13
- "last_freshness_check": null
13
+ "last_freshness_check": "2024-07-10T17:15:30.992561+00:00"
14
14
  },
15
15
  "iter": {
16
16
  "type": null,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rosters",
3
3
  "description": "nflfastR rosters",
4
- "last_local_update": "2023-12-28T05:46:15.090925",
4
+ "last_local_update": "2024-07-08T03:35:10.725351",
5
5
  "download_url": "https://github.com/nflverse/nflverse-data/releases/download/rosters/roster_{0}.csv",
6
6
  "compression": null,
7
7
  "engine": "c",
@@ -10,7 +10,7 @@
10
10
  "gh_api_endpoint": "https://api.github.com/repos/nflverse/nflverse-data/releases/tags",
11
11
  "gh_release_tag": "rosters",
12
12
  "sla_seconds": 900,
13
- "last_freshness_check": "2023-12-28T05:45:52.047895+00:00"
13
+ "last_freshness_check": "2024-07-10T17:16:08.157376+00:00"
14
14
  },
15
15
  "iter": {
16
16
  "type": "season",
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "wepa",
3
+ "description": "nfelo Weighted Expected Points Model",
4
+ "last_local_update": "2024-07-07T23:13:39.454179",
5
+ "download_url": "https://raw.githubusercontent.com/greerreNFL/wepa/main/data/wepa_by_game_pit.csv",
6
+ "compression": null,
7
+ "engine": "c",
8
+ "freshness": {
9
+ "type": "gh_commit",
10
+ "gh_api_endpoint": "https://api.github.com/repos/greerreNFL/wepa/commits?path=data/wepa_by_game_pit.csv",
11
+ "gh_release_tag": null,
12
+ "sla_seconds": 900,
13
+ "last_freshness_check": "2024-07-10T17:16:06.701316+00:00"
14
+ },
15
+ "iter": {
16
+ "type": null,
17
+ "start": null
18
+ },
19
+ "assignments": [],
20
+ "map": {
21
+ "Unnamed: 0": "int32",
22
+ "game_id": "object",
23
+ "team": "object",
24
+ "opponent": "object",
25
+ "season": "int32",
26
+ "game_number": "int32",
27
+ "margin": "float32",
28
+ "margin_against": "float32",
29
+ "epa": "float32",
30
+ "epa_against": "float32",
31
+ "epa_net": "float32",
32
+ "epa_net_opponent": "float32",
33
+ "wepa": "float32",
34
+ "d_wepa": "float32",
35
+ "wepa_net": "float32",
36
+ "wepa_against": "float32",
37
+ "d_wepa_against": "float32",
38
+ "wepa_net_opponent": "float32"
39
+ }
40
+ }
@@ -2,15 +2,15 @@
2
2
  "season_states": {
3
3
  "last_full_week": {
4
4
  "season": 2023,
5
- "week": 16
5
+ "week": 22
6
6
  },
7
7
  "last_partial_week": {
8
8
  "season": 2023,
9
- "week": 17
9
+ "week": 22
10
10
  },
11
11
  "next_week": {
12
- "season": 2023,
13
- "week": 18
12
+ "season": 2024,
13
+ "week": 1
14
14
  }
15
15
  }
16
16
  }
@@ -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}/Utilities/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['season_states'][state_type]['season'], global_variables['season_states'][state_type]['week']
@@ -0,0 +1,38 @@
1
+ import pandas as pd
2
+ import pathlib
3
+ import time
4
+
5
+ from .nfelodcm import get_df
6
+
7
+ def test_all_maps():
8
+ '''
9
+ Attempts to load all maps
10
+ '''
11
+ print('Testing all available maps')
12
+ map_loc = '{0}/Maps'.format(
13
+ pathlib.Path(__file__).parent.resolve()
14
+ )
15
+ maps = []
16
+ for f in pathlib.Path(map_loc).iterdir():
17
+ if f.is_file() and f.suffix == ".json":
18
+ maps.append(f.stem)
19
+ print(' Found {0} maps'.format(len(maps)))
20
+ if len(maps) > 0:
21
+ for table_map in maps:
22
+ print(' Loading {0}'.format(table_map))
23
+ ## first load ##
24
+ l1_start = time.time()
25
+ get_df(table_map)
26
+ l1_end = time.time()
27
+ print(' 1st load completed in {0} seconds'.format(round(
28
+ l1_end-l1_start,3
29
+ )))
30
+ ## second load
31
+ l2_start = time.time()
32
+ get_df(table_map)
33
+ l2_end = time.time()
34
+ print(' 2st load completed in {0} seconds'.format(round(
35
+ l2_end-l2_start,3
36
+ )))
37
+
38
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nfelodcm
3
- Version: 0.1.5
3
+ Version: 0.1.8
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>
@@ -2,6 +2,7 @@ README.md
2
2
  pyproject.toml
3
3
  ./__init__.py
4
4
  ./nfelodcm/nfelodcm.py
5
+ ./nfelodcm/tests.py
5
6
  ./nfelodcm/Engine/DCMTable.py
6
7
  ./nfelodcm/Engine/__init__.py
7
8
  ./nfelodcm/Engine/Assignments/__init__.py
@@ -15,13 +16,18 @@ pyproject.toml
15
16
  ./nfelodcm/Engine/Primatives/LocalIO.py
16
17
  ./nfelodcm/Engine/Primatives/TableMap.py
17
18
  ./nfelodcm/Engine/Primatives/__init__.py
19
+ ./nfelodcm/Maps/filmmargins.json
18
20
  ./nfelodcm/Maps/games.json
19
21
  ./nfelodcm/Maps/logos.json
22
+ ./nfelodcm/Maps/market_data.json
20
23
  ./nfelodcm/Maps/participants.json
21
24
  ./nfelodcm/Maps/pbp.json
25
+ ./nfelodcm/Maps/player_stats.json
26
+ ./nfelodcm/Maps/players.json
22
27
  ./nfelodcm/Maps/qbelo.json
23
28
  ./nfelodcm/Maps/qbr.json
24
29
  ./nfelodcm/Maps/rosters.json
30
+ ./nfelodcm/Maps/wepa.json
25
31
  ./nfelodcm/Utilities/__init__.py
26
32
  ./nfelodcm/Utilities/checks.py
27
33
  ./nfelodcm/Utilities/extract_map.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "nfelodcm"
7
- version = "0.1.5"
7
+ version = "0.1.8"
8
8
  readme = "README.md"
9
9
  requires-python = ">=3.11"
10
10
  license = {text = "MIT"}
@@ -1,3 +0,0 @@
1
- from .nfelodcm.nfelodcm import get_df
2
- from .nfelodcm.nfelodcm import load
3
- from .nfelodcm.nfelodcm import get_map
@@ -1,3 +0,0 @@
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
@@ -1,32 +0,0 @@
1
- import pandas as pd
2
-
3
- ## assignment functions that replaces fastr team names with legacy team names ##
4
- repl = {
5
- 'LV' : 'OAK',
6
- 'SD' : 'LAC',
7
- 'STL' : 'LAR',
8
- 'LA' : 'LAR',
9
- }
10
-
11
- def game_id_repl(df):
12
- """
13
- Replaces fastr game_ids with a legacy game id.
14
- """
15
- df['away_team'] = df['away_team'].replace(repl)
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 ##
26
- df['game_id'] = (
27
- df['season'].astype('str') + '_' +
28
- df['week'].astype('str').str.zfill(2) + '_' +
29
- df['away_team'] + '_' +
30
- df['home_team']
31
- )
32
- return df
@@ -1,70 +0,0 @@
1
- {
2
- "name": "logos",
3
- "description": "nflgamedata logos",
4
- "last_local_update": null,
5
- "download_url": "https://github.com/nflverse/nflfastR-data/raw/master/teams_colors_logos.csv",
6
- "compression": null,
7
- "engine": "c",
8
- "freshness": {
9
- "type": "gh_commit",
10
- "gh_api_endpoint": "https://api.github.com/repos/nflverse/nfldata/commits",
11
- "gh_release_tag": null,
12
- "sla_seconds": 900,
13
- "last_freshness_check": null
14
- },
15
- "iter": {
16
- "type": null,
17
- "start": null
18
- },
19
- "assignments": [
20
- "game_id_repl"
21
- ],
22
- "map": {
23
- "game_id": "object",
24
- "season": "int32",
25
- "game_type": "object",
26
- "week": "int32",
27
- "gameday": "object",
28
- "weekday": "object",
29
- "gametime": "object",
30
- "away_team": "object",
31
- "away_score": "float32",
32
- "home_team": "object",
33
- "home_score": "float32",
34
- "location": "object",
35
- "result": "float32",
36
- "total": "float32",
37
- "overtime": "float32",
38
- "old_game_id": "float32",
39
- "gsis": "float32",
40
- "nfl_detail_id": "object",
41
- "pfr": "object",
42
- "pff": "float32",
43
- "espn": "int32",
44
- "ftn": "float32",
45
- "away_rest": "int32",
46
- "home_rest": "int32",
47
- "away_moneyline": "float32",
48
- "home_moneyline": "float32",
49
- "spread_line": "float32",
50
- "away_spread_odds": "float32",
51
- "home_spread_odds": "float32",
52
- "total_line": "float32",
53
- "under_odds": "float32",
54
- "over_odds": "float32",
55
- "div_game": "int32",
56
- "roof": "object",
57
- "surface": "object",
58
- "temp": "float32",
59
- "wind": "float32",
60
- "away_qb_id": "object",
61
- "home_qb_id": "object",
62
- "away_qb_name": "object",
63
- "home_qb_name": "object",
64
- "away_coach": "object",
65
- "home_coach": "object",
66
- "referee": "object",
67
- "stadium_id": "object",
68
- "stadium": "object"
69
- }
70
- }
@@ -1,70 +0,0 @@
1
- {
2
- "name": "qbelo",
3
- "description": "538/nfelo QB Elo model",
4
- "last_local_update": "2023-12-28T05:45:51.537070",
5
- "download_url": "https://raw.githubusercontent.com/nflverse/nfldata/master/data/games.csv",
6
- "compression": null,
7
- "engine": "c",
8
- "freshness": {
9
- "type": "gh_commit",
10
- "gh_api_endpoint": "https://api.github.com/repos/nflverse/nfldata/commits",
11
- "gh_release_tag": null,
12
- "sla_seconds": 900,
13
- "last_freshness_check": "2023-12-28T05:45:51.100815+00:00"
14
- },
15
- "iter": {
16
- "type": null,
17
- "start": null
18
- },
19
- "assignments": [
20
- "game_id_repl"
21
- ],
22
- "map": {
23
- "game_id": "object",
24
- "season": "int32",
25
- "game_type": "object",
26
- "week": "int32",
27
- "gameday": "object",
28
- "weekday": "object",
29
- "gametime": "object",
30
- "away_team": "object",
31
- "away_score": "float32",
32
- "home_team": "object",
33
- "home_score": "float32",
34
- "location": "object",
35
- "result": "float32",
36
- "total": "float32",
37
- "overtime": "float32",
38
- "old_game_id": "float32",
39
- "gsis": "float32",
40
- "nfl_detail_id": "object",
41
- "pfr": "object",
42
- "pff": "float32",
43
- "espn": "int32",
44
- "ftn": "float32",
45
- "away_rest": "int32",
46
- "home_rest": "int32",
47
- "away_moneyline": "float32",
48
- "home_moneyline": "float32",
49
- "spread_line": "float32",
50
- "away_spread_odds": "float32",
51
- "home_spread_odds": "float32",
52
- "total_line": "float32",
53
- "under_odds": "float32",
54
- "over_odds": "float32",
55
- "div_game": "int32",
56
- "roof": "object",
57
- "surface": "object",
58
- "temp": "float32",
59
- "wind": "float32",
60
- "away_qb_id": "object",
61
- "home_qb_id": "object",
62
- "away_qb_name": "object",
63
- "home_qb_name": "object",
64
- "away_coach": "object",
65
- "home_coach": "object",
66
- "referee": "object",
67
- "stadium_id": "object",
68
- "stadium": "object"
69
- }
70
- }
File without changes
File without changes