def main(): teams = [] teamList = gen.readTeamListCsv(2018)['Teams'] pool = Pool() teams += pool.map(getTeamData, teamList) teams = sorted(teams, key=lambda k: k['Sponsors'], reverse=True) colOrder = ['Team', 'Name', 'Sponsors', 'Full Name'] gen.listOfDictToCSV("Team Sponsors", teams, colOrder)
normalEvents = [0, 1] rookieVal = 7400 maxTeam = 7900 perPage = 500 pages = round(maxTeam / perPage) yearStart = 2016 yearEnd = 2018 yearRange = range(yearStart, yearEnd + 1) teamList = {} eventList = {} for year in yearRange: teamList[year] = gen.readTeamListCsv(year)['Teams'].tolist() eventList[year] = slff.fetchNormalEventData(year) #teams = gen.readTeamListCsv(2019)['Teams'].tolist() teams = tba.district_teams('2019tx', False, True) #teams = ['frc125', 'frc401', 'frc7179'] eventFields = ['Code', 'Type', 'Week', 'Total Points', 'Award Points', 'Award Names', 'Draft Points', 'Rank Points', 'Elim Points', 'Rank'] teamData = {} for team in tqdm(teams): teamData[team] = {} for year in yearRange: teamData[team][year] = [] if team in teamList[year]: teamEvents = gen.readTeamCsv(team, 'events', year)
import gen teams = gen.readTeamListCsv(2018)['Teams'] records = [] for team in teams: matches = gen.readTeamCsv(team, 'matches', 2018) wins = 0 losses = 0 ties = 0 if matches is not None: for idx, match in matches.iterrows(): result = gen.matchResult(team, match) wins += result == 'WIN' losses += result == 'LOSS' ties += result == 'TIE' total = wins + losses + ties if total != 0: if wins == 0: wins = 1 total = total * 10 rating = wins / total wins = 0 else: rating = wins / total recordString = str(wins) + ' / ' + str(losses) + ' / ' + str(ties) records.append({
import gen YEAR = 2018 tba = gen.setup() teams = gen.readTeamListCsv(2018).Teams def fetchNames(robotList): print('memes') robotNames = [] for team in teams: robots = tba.team_robots(team) for robot in robots: if robot.year == 2018: robotNames.append({ 'name': robot.robot_name, 'length': len(robot.robot_name) }) print(len(robotNames)) robotNames = sorted(robotNames, key=lambda k: k['Length']) gen.listOfDictToCSV('robotNames', robotNames, ['Length', 'Name'])
import gen import pandas as pd from tqdm import tqdm tba = gen.setup() matchData = [] teamList = gen.readTeamListCsv(2018)['Teams'].tolist() for team in tqdm(teamList): teamMax = 0 yearMax = 0 for year in range(2008, 2019): matchesPlayed = len(tba.team_matches(team, None, year, False, True)) if matchesPlayed > teamMax: teamMax = matchesPlayed yearMax = year matchData.append({'Team': team, 'Max Matches': teamMax, 'Year': year}) matchDf = pd.DataFrame(matchData).sort_values('Max Matches').to_csv( 'TeamMaxMatches.csv', index=False)
import gen import slff currentYear = 2018 rookieYear = 2006 prevTeams = gen.readTeamListCsv(rookieYear - 1)['Teams'] currTeams = gen.readTeamListCsv(rookieYear)['Teams'] rookies = [] for team in currTeams: prevYears = slff.getTeamYears(team, rookieYear - 1) if len(prevYears) == 0: print(team) #Event data (ranks, opr) events = gen.readTeamCsv(team, 'events', currentYear) ranks = [] oprs = [] avgOpr = 0 avgRank = 99 if events is not None: for event in events['Event']: rank = gen.readEventCsv(event, 'rankings') opr = gen.readEventCsv(event, 'opr') if opr is not None: oprs.append(opr[opr.Team == team]['OPR'].values[0]) else: print("Couldn't get OPR data for", event) if rank is not None:
import gen currentTeams = gen.readTeamListCsv(2019) teamGaps = {x: {'Max Gap': 0, 'Current Gap': 0} for x in currentTeams['Teams']} for year in range(1992, 2019): yearTeams = gen.readTeamListCsv(year) for team in currentTeams['Teams']: entry = teamGaps[team] if team in yearTeams['Teams'].unique(): teamYearEvents = gen.readTeamCsv(team, 'events', year) champTypes = [3, 4] if any(elem in champTypes for elem in teamYearEvents['Type']): if entry['Current Gap'] > entry['Max Gap']: entry['Max Gap'] = entry['Current Gap'] entry['Current Gap'] = 0 else: entry['Current Gap'] += 1 for team in teamGaps: entry = teamGaps[team] if entry['Current Gap'] > entry['Max Gap']: entry['Max Gap'] = entry['Current Gap']
def main(): global teams pool = Pool() teamData = {} teamList = gen.readTeamListCsv(currentYear, ['Teams'])['Teams'] for team in teamList: teams[team] = {'playValues': [], 'awardValues': [], 'totalValues': []} for year in years: teams[team][str(year)] = {'playPoints': 0, 'awardPoints': 0} for idx, year in enumerate(years): gen.progressBar(idx, len(years)) teamData[str(year)] = [] teamData[str(year)] = pool.map(partial(getData, year), teamList) for year in teamData: for t in teamData[year]: teams[t['team']][year]['playPoints'] = t['playPoints'] teams[t['team']][year]['awardPoints'] = t['awardPoints'] outData = [] for team in teams: playValues = [teams[team][str(year)]['playPoints'] for year in years] awardValues = [teams[team][str(year)]['awardPoints'] for year in years] totalValues = [ teams[team][str(year)]['playPoints'] + teams[team][str(year)]['awardPoints'] for year in years ] avgPlay = stat.mean(playValues) avgAward = stat.mean(awardValues) avgTotal = stat.mean(totalValues) maxPlay = max(playValues) maxAward = max(awardValues) maxTotal = max(totalValues) teamObj = { 'Team': team[3:], 'Average Play': avgPlay, 'Average Award': avgAward, 'Average Total': avgTotal, 'Max Play': maxPlay, 'Max Award': maxAward, 'Max Total': maxTotal } for idx, year in enumerate(years): teamObj[str(year) + ' Play'] = playValues[idx] teamObj[str(year) + ' Award'] = awardValues[idx] teamObj[str(year) + ' Total'] = totalValues[idx] outData.append(teamObj) colOrder = [ 'Team', 'Average Play', 'Average Award', 'Average Total', 'Max Play', 'Max Award', 'Max Total' ] for year in range(currentYear - yearRange + 1, currentYear + 1): colOrder.append(str(year) + ' Play') colOrder.append(str(year) + ' Award') colOrder.append(str(year) + ' Total') gen.listOfDictToCSV("Worldwide Regional", outData, colOrder)
import gen import pandas as pd from tqdm import tqdm tba = gen.setup() teamDf = pd.read_csv('rawTeams.csv', header=None, index_col=0) teams2019 = gen.readTeamListCsv(2019)['Teams'] names = [] for team in tqdm(teams2019): if team in teamDf.index: names.append({'Team': team[3:], 'Name': teamDf.loc[team][1]}) else: names.append({'Team': team[3:], 'Name': tba.team(team)['nickname']}) gen.listOfDictToCSV('Team Names', names, ['Team', 'Name'])