title: How to fill nan values with rolling mean in pandas
body: <p>I have a dataframe which contains nan values at few places. I am trying to perform data cleaning in which I fill the nan values with mean of it's previous five instances. To do so, I have come up with the following.</p>
  
  <pre><code>input_data_frame[var_list].fillna(input_data_frame[var_list].rolling(5).mean(), inplace=True)
  </code></pre>
  
  <p>But, this is not working. It isn't filling the nan values. There is no change in the dataframe's null count before and after the above operation. Assuming I have a dataframe with just integer column, How can I fill NaN values with mean of the previous five instances? Thanks in advance.</p>