import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import trueskill as ts

dfResults = pd.read_csv('../input/201608-SanFracisco-HydrofoilProTour.csv')

def doRating(numRaces, dfResults):
    for raceCol in range(1, numRaces + 1):
        dfResults['Rating'] = ts.rate(list(zip(dfResults['Rating'].T.values.tolist())), ranks=dfResults['R' + raceCol].T.values.tolist())

dfResults = doRating(16, dfResults)

dfResults['Rating'] = ts.Rating()

ts.rate([ts.Rating(), ts.Rating()], ranks=[1, 0])