I am trying to develop some code to preprocess some data for an Autoregressive algorithm. In order to do so, I am adding new columns to the dataFrame I am using for the learning process (these new columns contain former values of the output). I am doing so with the following code, after struggling quite a lot:
for i in range(0, n):
tmpOutput = pd.Series(output.ix[i:len(output.index)-n+i, 1])
tmpOutput.index = range(n, len(output.index) + 1)
tmpOutput.name = 'T-' + str(n-i)
tmp = tmp.join([tmpOutput])
You could see I am first extracting some data and building a Series from it; I then modify the index and rename the series (to avoid some naming conflict in my loop) and finally, I perform a join. I was wandering if this code can be enhanced, if there exists an alternative way, with better performances.