title: Get first row of dataframe in Python Pandas based on criteria
body: <p>Let's say that I have a dataframe like this one</p>
  
  <pre><code>import pandas as pd
  df = pd.DataFrame([[1, 2, 1], [1, 3, 2], [4, 6, 3], [4, 3, 4], [5, 4, 5]], columns=['A', 'B', 'C'])
  
  &gt;&gt; df
     A  B  C
  0  1  2  1
  1  1  3  2
  2  4  6  3
  3  4  3  4
  4  5  4  5
  </code></pre>
  
  <p>The original table is more complicated with more columns and rows.</p>
  
  <p>I want to get the first row that fulfil some criteria. Examples:</p>
  
  <ol>
  <li>Get first row where A > 3 (returns row 2)</li>
  <li>Get first row where A > 4 AND B > 3 (returns row 4)</li>
  <li>Get first row where A > 3 AND (B > 3 OR C > 2) (returns row 2)</li>
  </ol>
  
  <p>But, if there isn't any row that fulfil the specific criteria, then I want to get the first one after I just sort it descending by A (or other cases by B, C etc)</p>
  
  <ol start="4">
  <li>Get first row where A > 6 (returns row 4 by ordering it by A desc and get the first one)</li>
  </ol>
  
  <p>I was able to do it by iterating on the dataframe (I know that craps :P). So, I prefer a more pythonic way to solve it.</p>