Beispiel #1
0
 def test_create_table(self):
     PATH = Path('tests/fixtures/table_columns.json')
     columns = load_json(PATH)
     loader = NflLoader()
     season, week, team = (2018, 1, 'CAR')
     table = loader.get_game_table(season, week, team, update_schedule=False, new=True)
     self.assertListEqual(columns, list(table.columns))
Beispiel #2
0
 def test_add_fpts(self):
     PATH = Path('tests/fixtures/test_fpts.csv')
     df = pd.read_csv(PATH)
     loader = NflLoader()
     df = loader.add_fpts(df)
     fpts_calculated = list(df['fpts'])
     fpts_soll = list(df['soll_fpts'])
     self.assertListEqual(fpts_calculated, fpts_soll)
Beispiel #3
0
def get_stats_from_current_season(weeks: list):
    season = 2019
    loader = NflLoader(season)
    weekdata = []
    for week in weeks:
        weekdata.append(loader.get_weektable(week))
    df = pd.concat(weekdata, sort=False)
    df.to_csv(loader.datapath.parent / f"{season}_REG.csv")
    print(df.head())
Beispiel #4
0
 def test_get_game_eid(self):
     nloader = NflLoader()
     eid = nloader.get_game_eid("test", "test_sched", "test_team", update_schedule=False)
     self.assertEqual(eid, "test_eid")
Beispiel #5
0
 def test_get_game_stats(self):
     nloader = NflLoader()
     nloader.datapath = Path('tests/database')
     stats = nloader.get_game_stats("test_eid")
     self.assertEqual(stats['test_eid']['home']['abbr'], "test_team")
Beispiel #6
0
def get_pre_season(season: int):
    loader = NflLoader(season, seasontype='PRE')
    stable = loader.get_seasontable()
    return stable
Beispiel #7
0
def get_stats():
    seasons = (2014, 2015, 2016)
    for season in seasons:
        nl = NflLoader(season, save=True)
        _ = nl.get_seasontable()