예제 #1
0
 def runTest(self):
     stats = pd.DataFrame([dict(PLAYER='Kobe', POS='SG'), dict(PLAYER='T-Mac', POS='SG'),\
                           dict(PLAYER='Yao Ming', POS='C'), dict(PLAYER='Tim Duncan', POS='PF'),\
                           dict(PLAYER='Kevin Garnett', POS='PF'), dict(PLAYER='LeBron', POS='SF'),\
                           dict(PLAYER='Kevin Durant', POS='SF'), dict(PLAYER='Melo', POS='SF'),\
                           dict(PLAYER='Steve Nash', POS='PG')])
     counts = count_position(stats)
     self.assertTrue((counts == np.array([1, 2, 3, 2, 1])).all())
예제 #2
0
 def runTest(self):
     stats = pd.DataFrame([dict(PLAYER='Kobe', POS='SG'), dict(PLAYER='T-Mac', POS='SG'),\
                           dict(PLAYER='Yao Ming', POS='C'), dict(PLAYER='Tim Duncan', POS='PF'),\
                           dict(PLAYER='Kevin Garnett', POS='PF'), dict(PLAYER='LeBron', POS='SF'),\
                           dict(PLAYER='Kevin Durant', POS='SF'), dict(PLAYER='Melo', POS='SF'),\
                           dict(PLAYER='Steve Nash', POS='PG')])
     counts = count_position(stats)
     self.assertTrue((counts==np.array([1, 2, 3, 2, 1])).all())
예제 #3
0
 def get(self):
     position_counts = {}    # store position counts for each year
     for year in YEARS:
         try:
             stats = pd.read_csv(FILE_DIR + '/nbastats/static/data/stats_{}.csv'.format(year))
         except IOError as e:
             continue
         position_counts[year] = utility.count_position(stats)
     self.write(rendering.render_league_info(position_counts, TEMPLATE_DIR, 'league_info.html'))
예제 #4
0
 def get(self):
     position_counts = {}  # store position counts for each year
     for year in YEARS:
         try:
             stats = pd.read_csv(
                 FILE_DIR +
                 '/nbastats/static/data/stats_{}.csv'.format(year))
         except IOError as e:
             continue
         position_counts[year] = utility.count_position(stats)
     self.write(
         rendering.render_league_info(position_counts, TEMPLATE_DIR,
                                      'league_info.html'))