title: Fill NaN based on previous value of row
body: <p>I have a data frame (sample, not real):</p>
  
  <p>df = </p>
  
  <pre><code>    A   B   C    D   E     F       
  
  0   3   4   NaN  NaN NaN   NaN  
  1   9   8   NaN  NaN NaN   NaN      
  2   5   9   4    7   NaN   NaN  
  3   5   7   6    3   NaN   NaN  
  4   2   6   4    3   NaN   NaN  
  </code></pre>
  
  <p>Now I want to fill NaN values with previous couple(!!!) values of row (fill Nan with left existing couple of numbers and apply to the whole row) and apply this to the whole dataset.</p>
  
  <ul>
  <li>There are a lot of answers concerning filling the columns. But in
  this case I need to fill based on rows.</li>
  <li>There are also answers related to fill NaN based on other column, but
  in my case number of columns are more than 2000. This is sample data</li>
  </ul>
  
  <p>Desired output is:</p>
  
  <p>df = </p>
  
  <pre><code>   A  B   C  D  E  F  
  
  0  3  4   3  4  3  4  
  1  9  8   9  8  9  8  
  2  5  9   4  7  4  7      
  3  5  7   6  3  6  3  
  4  2  6   4  3  4  3  
  </code></pre>