title: pandas DataFrame: replace nan values with average of columns
body: <p>I've got a pandas DataFrame filled mostly with real numbers, but there is a few <code>nan</code> values in it as well.</p>
  
  <p>How can I replace the <code>nan</code>s with averages of columns where they are?</p>
  
  <p>This question is very similar to this one: <a href="https://stackoverflow.com/questions/18689235/numpy-array-replace-nan-values-with-average-of-columns">numpy array: replace nan values with average of columns</a>  but, unfortunately, the solution given there doesn't work for a pandas DataFrame.</p>