title: How to preprocess time series data in Python for forecasting
body: <p>I'm trying to prepare some time-series data (Forex) for forecasting in Python. The plan is to transform the time series into a 2-D Numpy array which will be passed to R as an R matrix via PypeR to train an ANFIS (adaptive neuro-fuzzy inference system) for forecasting. (The reasons why I would go through a process so convoluted are purely academic.) This would require that the first n columns be the last n data points and the (n + 1)th column be the current/predicted value.</p>
  
  <p>Consider the following data points:</p>
  
  <pre><code>Date    AUD-USD
  9/1/1999    0.6452
  9/2/1999    0.6466
  9/3/1999    0.6466
  9/4/1999    0.6466
  9/5/1999    0.6459
  9/6/1999    0.6494
  9/7/1999    0.6479
  9/8/1999    0.653
  9/9/1999    0.6512
  </code></pre>
  
  <p>For simplicity's sake, let's say that the five previous points will be used as inputs to predict the next data point. The array should, then, look something like:</p>
  
  <pre><code>            t - 5   t - 4   t - 3   t - 2   t - 1   t
  9/6/1999    0.6452  0.6466  0.6466  0.6466  0.6459  0.6494
  9/7/1999    0.6466  0.6466  0.6466  0.6459  0.6494  0.6479
  9/8/1999    0.6466  0.6466  0.6459  0.6494  0.6479  0.653
  9/9/1999    0.6466  0.6459  0.6494  0.6479  0.653   0.6512
  </code></pre>
  
  <p>minus the dates (just there for clarity's sake).</p>
  
  <p>The question is this: Is there an existing Python function or library that will achieve the desired results? Or is this best done by hand through a series of loops? Additionally, is this process called something? I can't seem to Google a solution, so maybe I just don't know what word to call this.</p>