title: How to fill NaN with aggregate value of closest point by continous varuiable?
body: <p>Let's say I have the following dataset</p>
  <pre class="lang-py prettyprint-override"><code>     A    B
  0    1    1
  1    NaN  3
  2    5    2
  3    7    4
  4    NaN  3
  5    3    3
  </code></pre>
  <p>I want to fill NaNs with some function, for example mean, of values <code>A</code> of nearest neighbors by <code>B</code> by given threshold. For example, if threshold is 1, then</p>
  <p>for object 0 neighbors are object 2 (because 2 - 1 &lt;= 1)</p>
  <p>for object 1 neighbors are objects 2, 3, 4, 5</p>
  <p>and so on
  so the result would be</p>
  <pre class="lang-py prettyprint-override"><code>     A    B
  0    1    1
  1    5    3   # 5 = (5 + 7 + 3) / 3
  2    5    2
  3    7    4
  4    5    3   # 5 = (5 + 7 + 3) / 3
  5    3    3
  </code></pre>
  <p>If NaNs are faced in computations, they are neglected. How can I do that?</p>