title: Pandas - Select rows based on other rows
body: <p>Let's say I have a dataframe:</p>
  
  <pre><code>df = pd.DataFrame({'A':[1,2,3,3,6,8,1,4]})
  
  df
     A
  0  1
  1  2
  2  3
  3  3
  4  6
  5  8
  6  1
  7  4
  </code></pre>
  
  <p>And I want to select rows which are preceded by a row that contains a one:</p>
  
  <pre><code>selection
     A
  1  2
  7  4
  </code></pre>
  
  <p>Right now, I can solve this by selecting rows with ones, getting their indices, and then adding one to the indices and then using iloc:</p>
  
  <pre><code>df.iloc[df[df.A == 1].index + 1]
  </code></pre>
  
  <p>But I'm wondering if there is a "more pandas" way to do this.  Further, if the search was more complicated like:  select all rows preceded by a 1 and followed by a 3.  Or what if the index wasn't just integers, but timestamps. How do I express inter-row dependencies cleanly?</p>