title: (pandas) Fill NaN based on groupby and column condition
body: <p>Using 'bfill' or 'ffill' on a groupby element is trivial, but what if you need to fill the na with a specific value in a second column, based on a condition in a third column?</p>
  
  <p>For example:</p>
  
  <pre><code>&gt;&gt;&gt; df=pd.DataFrame({'date':['01/10/2017', '02/09/2017', '02/10/2016','01/10/2017', '01/11/2017', '02/10/2016'], 'a':[1,1,1,2,2,2], 'b':[4,np.nan,6, 5, np.nan, 7]})
  &gt;&gt;&gt; df
     a    b        date
  0  1  4.0  01/10/2017
  1  1  NaN  02/09/2017
  2  1  6.0  02/10/2016
  3  2  5.0  01/10/2017
  4  2  NaN  01/11/2017
  5  2  7.0  02/10/2016
  </code></pre>
  
  <p>I need to group by column 'a', and fill the NaN with the column 'b' value where the date for that row is closest to the date in the NaN row.</p>
  
  <p>So the output should look like:</p>
  
  <pre><code>   a    b        date
  0  1  4.0  01/10/2017
  1  1  6.0  02/09/2017
  2  1  6.0  02/10/2016
  3  2  5.0  01/10/2017
  4  2  5.0  01/11/2017
  5  2  7.0  02/10/2016
  </code></pre>
  
  <p>Assume there is a closest_date() function that takes the NaN date and the list of other dates in that group, and returns the closest date.</p>
  
  <p>I'm trying to find a clean solution that doesn't have to iterate through rows, ideally able to use apply() with lambdas. Any ideas?</p>