Esempio n. 1
0
def parseSeasons():
  start = time.clock()

  first_year = 2000
  last_year = 2017
  min_minutes_played = 10.0
  min_games = 20
  players = []
  all_seasons_by_age = dict()
  for year in range(first_year, last_year + 1):
    this_season = Season()
    try:
      sorted_players = this_season.calcSeason('season/' + str(year) + 'Stats.txt', year, min_minutes_played, min_games)
    except IndexError:
      print(str(year))
    for player in sorted_players:
      seasons = player.getSeason(year)
      hold = dict()
      if int(seasons.age) in all_seasons_by_age:
        hold = all_seasons_by_age[int(seasons.age)]
      hold[seasons] = player
      all_seasons_by_age[int(seasons.age)] = hold
      if player in players:
        player_season = players[players.index(player)]
        player_season.addPSeason(year, player)
        players[players.index(player)] = player_season
      else:
        players.append(player)

  for year in range(first_year, last_year + 1):
    advanced_file = open('season/' + str(year) + 'AdvancedStats.txt', 'r')
    for line in advanced_file:
      advanced_stats = line.split('\t')
      player_name = advanced_stats[AdvancedReferenceColumns.name.value]
      fake_player = NbaPlayer(player_name, 'PG', 1990, {})
      if fake_player not in players:
        continue
      player_index = players.index(fake_player)
      if not players[player_index].hasSeason(year):
        continue
      player_season = players[player_index].getSeason(year)
      player_season.setPer(float(advanced_stats[AdvancedReferenceColumns.per.value]))
      player_season.setBpm(float(advanced_stats[AdvancedReferenceColumns.bpm.value]))
      player_season.setVorp(float(advanced_stats[AdvancedReferenceColumns.vorp.value]))
      player = players[player_index]
      player.addSeason(year, player_season)
      players[player_index] = player
    advanced_file.close()

  end = time.clock()
  print 'time: ' + str(end-start)
  return players
import os
import sys
from season import Season
from nbaplayer import NbaPlayer
from score import Score
year = 2013
se = Season()
sortedPlayers = se.calcSeason('season/nextSeason.txt', year, 0, 0, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1)
scores = []
for p in sortedPlayers:
  se = p.getSeason(year)
  if ("PG" in p.position):
    scores.append(Score(p.name, se.zScore(1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0), se.zScore()))
scores = sorted(scores)
for j in scores:
  print(j.name + "\t" + str(j.score) + "\t" + str(j.extra))
Esempio n. 3
0
import os
import sys
from season import Season
from nbaplayer import NbaPlayer
from score import Score
year = 2013
se = Season()
sortedPlayers = se.calcSeason('season/thisStats.txt', year, 3, 1, 2, 28, 23, 22, 24, 25, 26, 10, 19, 11, 7)
scores = []
for p in sortedPlayers:
  se = p.getSeason(year)
  if ("SF" in p.position):
    scores.append(Score(p.name, se.zScore(1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0), se.zScore()))
scores = sorted(scores)
for j in scores:
  print(j.name + "\t" + str(j.score) + "\t" + str(j.extra))
Esempio n. 4
0
from AdvancedReferenceColumns import AdvancedReferenceColumns
from season import Season
from nbaplayer import NbaPlayer
from score import Score

start = time.clock()

first_year = 2000
last_year = 2014
min_minutes_played = 10.0
min_games = 20
players = []
all_seasons_by_age = dict()
for year in range(first_year, last_year + 1):
  this_season = Season()
  sorted_players = this_season.calcSeason('season/' + str(year) + 'Stats.txt', year, min_minutes_played, min_games)
  for player in sorted_players:
    seasons = player.getSeason(year)
    hold = dict()
    if int(seasons.age) in all_seasons_by_age:
      hold = all_seasons_by_age[int(seasons.age)]
    hold[seasons] = player
    all_seasons_by_age[int(seasons.age)] = hold
    if player in players:
      player_season = players[players.index(player)]
      player_season.addPSeason(year, player)
      players[players.index(player)] = player_season
    else:
      players.append(player)

for year in range(first_year, last_year + 1):
Esempio n. 5
0
import os
import sys
from season import Season
from nbaplayer import NbaPlayer
from score import Score

year = 2014
season = Season()
sortedPlayers = season.calcSeason("season/nextSeason.txt", year, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1)
scores = []
for p in sortedPlayers:
    se = p.getSeason(year)
    r = se.zScore()
    scores.append(Score(p.name, r))
scores = sorted(scores)
for j in scores:
    print(str(j.name) + "\t" + str(j.score))