title: How to access individual elements within a rolling window on a dataframe
body: <p>I have a dataframe with the quarterly U.S. GDP as column values. I would like to look at the values, 3 at a time, and find the index where the GDP fell for the next two consecutive quarters. This means I need to compare individual elements within df['GDP'] with each other, in groups of 3. </p>
  
  <p>Here's an example dataframe.</p>
  
  <pre><code>df = pd.DataFrame(data=np.random.randint(0,10,10), columns=['GDP'])
  df
  
      GDP
  0   4
  1   4
  2   4
  3   1
  4   4
  5   4
  6   8
  7   2
  8   3
  9   9
  </code></pre>
  
  <p>I'm using <code>df.rolling().apply(find_recession)</code>, but I don't know how I can access individual elements of the rolling window within my <code>find_recession()</code> function.</p>
  
  <pre><code>gdp['Recession_rolling'] = gdp['GDP'].rolling(window=3).apply(find_recession_start)
  </code></pre>
  
  <p>How can I access individual elements within the rolling window, so I can make a comparison such as gdp_val_2 &lt; gdp_val_1 &lt; gdp_val? </p>
  
  <p>The .rolling().apply() will go through the entire dataframe, 3 values at a time, so let's take a look at one particular window, which starts at index location 6:</p>
  
  <pre><code>   GDP
  6  8   # &lt;- gdp_val
  7  2   # &lt;- gdp_val_1
  8  3   # &lt;- gdp_val_2
  </code></pre>
  
  <p>How can I access gdp_val, gdp_val_1, and gdp_val_2 within the current window?</p>