Pandas: Get ohlc data for every row
<p>I have a <code>DataFrame</code>with a <code>datetime</code> index and a price column. I want ohlc data. (open, high, low, close)</p>

<p>I want to resample this dataframe at a given frequency <em>at every row</em>.</p>

<p><code>frame.resample('60S', how = 'ohlc')</code> works but now the dataframe's indexs are spaced 60 seconds apart. I want to resample at every row from the previous 60s worth of rows. (12 if indexs are 5s apart). That way I can have ohlc values for every row in the original dataframe.</p>

<p>I dont think what I want to do is possible with <code>df.resample</code> but possibly with <code>.agg</code> or <code>.map</code>?</p>

<p>How do I get ohlc data for <em>every</em> row?</p>

<pre><code>n = 10000

prices = np.linspace(100.0, 103.0, n) + np.random.normal(0.0, 0.3, n)
f = pd.DataFrame({'price': prices}, index = pd.date_range(end = datetime.utcnow(), freq = '5S', periods = n))

ohlcized = f.resample('60S', how = 'ohlc') # resampling doesnt work (834 != 10000)
len(ohlcized) # 834
len(f) # 10000

if len(ohlcized) == len(f):
    print "question answered"
</code></pre>