def calculateFirstDifference(filePath, outputFilePath):
    """
    Create an auxiliary data file that contains first difference of the predicted field
    :param filePath: path of the original data file
    """
    predictedField = SWARM_CONFIG['inferenceArgs']['predictedField']

    data = pd.read_csv(filePath, header=0, skiprows=[1,2])
    predictedFieldVals = data[predictedField].astype('float')
    firstDifference = predictedFieldVals.diff()
    data[predictedField] = firstDifference

    inputFile = open(filePath, "r")
    outputFile = open(outputFilePath, "w")
    csvReader = csv.reader(inputFile)
    csvWriter = csv.writer(outputFile)
    # write headlines
    for _ in xrange(3):
      readrow = csvReader.next()
      csvWriter.writerow(readrow)
    for i in xrange(len(data)):
      csvWriter.writerow(list(data.iloc[i]))

    inputFile.close()
    outputFile.close()
def calculateFirstDifference ( filePath , outputFilePath ) : predictedField = SWARM_CONFIG [ 'inferenceArgs' ] [ 'predictedField' ] data = pd . read_csv ( filePath , header = 0 , skiprows = [ 1 , 2 ] ) predictedFieldVals = data [ predictedField ] . astype ( 'float' ) firstDifference = predictedFieldVals . diff ( ) data [ predictedField ] = firstDifference inputFile = open ( filePath , "r" ) outputFile = open ( outputFilePath , "w" ) csvReader = csv . reader ( inputFile ) csvWriter = csv . writer ( outputFile ) for _ in xrange ( 3 ) : readrow = csvReader . next ( ) csvWriter . writerow ( readrow ) for i in xrange ( len ( data ) ) : csvWriter . writerow ( list ( data . iloc [ i ] ) ) inputFile . close ( ) outputFile . close ( )
Create an auxiliary data file that contains first difference of the predicted field
    :param filePath: path of the original data file