pd.rolling_max and min with groupby or similar
<p>Using the following code I am able to capture the rolling high and low of my data in the <code>H1_high</code>and <code>H1_low</code> columns.   </p>

<pre><code>data["H1_high"] = pd.rolling_max(data.High, window=60, min_periods=1)
data["H1_low"] = pd.rolling_min(data.Low, window=60, min_periods=1)
</code></pre>

<p>This gives the following output:</p>

<pre><code>                    Open    High    Low Last    Volume  H1_high H1_low
Timestamp                           
2014-03-04 09:30:00 1783.50 1784.50 1783.50 1784.50 171 1784.50 1783.5
2014-03-04 09:31:00 1784.75 1785.75 1784.50 1785.25 28  1785.75 1783.5
2014-03-04 09:32:00 1785.00 1786.50 1785.00 1786.50 81  1786.50 1783.5
2014-03-04 09:33:00 1786.00 1786.00 1785.25 1785.25 41  1786.50 1783.5
2014-03-04 09:34:00 1785.00 1785.25 1784.75 1785.25 11  1786.50 1783.5
2014-03-04 09:35:00 1785.50 1786.75 1785.50 1785.75 49  1786.75 1783.5
2014-03-04 09:36:00 1786.00 1786.00 1785.25 1785.75 12  1786.75 1783.5
2014-03-04 09:37:00 1786.00 1786.25 1785.25 1785.25 15  1786.75 1783.5
</code></pre>

<p>What I would like to do is only capture the <code>H1_high</code>and <code>H1_low</code> between the following times:</p>

<pre><code>daystart = '9:30'
IB_end = '10:29:59'

IB_session = data.between_time(daystart,IB_end, include_start=True, include_end=True)
</code></pre>

<p>and do this on a daily basis showing the <code>H1_high</code>and <code>H1_low</code> then carrying forward (FFill) the last value from  <code>IB_end = '10:29:59'</code> to the end of the day (16:14:00).</p>

<p>So here is desired output for <code>H1_high</code> <code>H1_low</code> columns: </p>

<pre><code>                    H1_high H1_low
2014-03-04 10:29:00 1786.75 1783.5
2014-03-04 10:30:00 1786.75 1783.5
2014-03-04 10:31:00 1786.75 1783.5
</code></pre>

<p>final value from <code>10:29:59</code> fills forward until end of day:</p>

<pre><code>                    H1_high H1_low
2014-03-04 16:14:00 1786.75 1783.5
</code></pre>

<p>then new day starts again with fresh values:</p>

<pre><code>                    H1_high H1_low
2014-03-05 09:30:00 1788.00 1783.00
</code></pre>

<p>use <code>datetime.time</code> and filter your index</p>

<pre><code>import datetime

high_low_xt = lambda df: pd.concat([df.High.cummax(), df.Low.cummin()], axis=1)
tidx = pd.date_range('2016-09-14', '2016-09-16', freq='T')

start = datetime.time(9, 30)
end = datetime.time(10, 30)
eod = datetime.time(18, 14)

bidx = tidx[(tidx.time &gt;= start) &amp; (tidx.time &lt; end)]
didx = tidx[(tidx.time &gt;= start) &amp; (tidx.time &lt;= eod)]

df = pd.DataFrame(np.random.rand(len(tidx), 2), tidx, ['High', 'Low'])
df1 = df.ix[bidx].groupby(pd.TimeGrouper('D')).apply(high_low_xt)

df1.reindex(didx, method='ffill')
</code></pre>

<p><a href="http://i.stack.imgur.com/eyQk7.png" rel="nofollow"><img src="http://i.stack.imgur.com/eyQk7.png" alt="enter image description here"></a></p>

python pandas