title: Find index of first row closest to value in pandas DataFrame
body: <p>So I have a dataframe containing multiple columns. For each column, I would like to get the index of the first row that is nearly equal to a user specified number (e.g. within 0.05 of desired number). The dataframe looks kinda like this:</p>
  
  <pre><code>ix   col1   col2   col3
  0    nan    0.2    1.04
  1    0.98   nan    1.5
  2    1.7    1.03   1.91
  3    1.02   1.42   0.97
  </code></pre>
  
  <p>Say I want the first row that is nearly equal to 1.0, I would expect the result to be: </p>
  
  <ul>
  <li>index 1 for col1 (not index 3 even though they are mathematically equally close to 1.0)</li>
  <li>index 2 for col2</li>
  <li>index 0 for col3 (not index 3 even though 0.97 is closer to 1 than 1.04)</li>
  </ul>
  
  <p>I've tried an approach that makes use of argsort():</p>
  
  <pre><code>df.iloc[(df.col1-1.0).abs().argsort()[:1]]
  </code></pre>
  
  <p>This would, according to other topics, give me the index of the row in col1 with the value closest to 1.0. However, it returns only a dataframe full of nans. I would also imagine this method does not give the first value close to 1 it encounters per column, but rather the value that is closest to 1.</p>
  
  <p>Can anyone help me with this?</p>