def set_historical(self, week, season): if self.name in self._PLAYER_DATA_CACHE: self.__set_from_data_cache( self._PLAYER_DATA_CACHE[self.name]) return try: scores = NFLDK.get_weekly_scores( name=self.name, weeks=range(1, week), season=season ) scores = [ s.get('stats', 0) for s in scores ] self.all_scores = scores self.last_score = scores[-1] self.max_score = max(scores) self.min_score = min(scores) self.average_score = min(scores) self.median_score = np.median(scores) self.stdev_score = np.std(scores) self.__set_data_cache() print('Fetched player data for {}'.format(self.name)) except Exception: self._PLAYER_DATA_CACHE[self.name] = None print('Failed to fetch player data for {}'.format(self.name))