def generate_new_round(dframeList, currentBand, this_round, handicap = False): dframe = dframeList[currentBand] sortedFrame = MMS.sort_by_mms(dframeList, currentBand, False, handicap) oppset = {} for i,item in sortedFrame['history'].iteritems(): os=set() if (item!=""): for opp in item.split(";"): if (opp.lower() != 'bye'): os.add(int(opp[1:-1])) oppset[sortedFrame['id'][i]]=os finalPairing = {} currentIndex = [] currentSet = set() finalList = [] if (this_round == 0): #special treatment for the very first round for performance consideration first_pairing = get_foldpairing(len(sortedFrame)) finalList.append((0, first_pairing)) else: totalCount = [0] get_mutation(sortedFrame, 0, finalPairing, currentIndex, currentSet, oppset, totalCount) topPairings = sorted(finalPairing.iteritems())[0] random.shuffle(topPairings[1]) for item in topPairings[1]: finalList.append((topPairings[0], item)) return finalList, sortedFrame
def azureml_main(dataframe1 = None, results = None): # Execution logic goes here if (dataframe1 is None): return pandas.DataFrame(columns=['id','name','rank','history']) rawframe = dataframe1.fillna("") df, handicap = read_round(rawframe) for i in range(0, len(df)-1): df[i] = update_round(df[i], results) df[i] = MMS.sort_by_mms(df, i, dropAux=False, handicap=handicap[i]) #allStanding.append(dfRound[i].copy()) #newframe = update_round(rawframe, results) #newframe = pandas.concat(df, ignore_index=True) newframe = df[0] for i in range(1, len(df)-1): if handicap[i]: newframe.loc[len(newframe)] = ['&','&','&','&','&','&','&'] else: newframe.loc[len(newframe)] = ['=','=','=','=','=','=','='] newframe = newframe.append(df[i]) # If a zip file is connected to the third input port is connected, # it is unzipped under ".\Script Bundle". This directory is added # to sys.path. Therefore, if your zip file contains a Python file # mymodule.py you can import it using: # import mymodule # Return value must be of a sequence of pandas.DataFrame return newframe