title: How to assign minimum value based on rank in pandas?
body: <p>I have a dataframe which looks like this:</p>
  <pre><code>pd.DataFrame({'A': ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'],
    ...:                     'rank': [1, 2, 3, 4, 5, 6, 7, 8],
    ...:                     'value': [8, 6, np.nan, 7, 9, np.nan, 4, np.nan]})
  Out[4]: 
     A  rank  value
  0  A     1    8.0
  1  B     2    6.0
  2  C     3    NaN
  3  D     4    7.0
  4  E     5    9.0
  5  F     6    NaN
  6  G     7    4.0
  7  H     8    NaN
  </code></pre>
  <p>For all NaN values I would like to assign the minimum value of the group of items that are ranked above its own rank.</p>
  <p>Logic:</p>
  <p>C has a rank of 3, the 2 items ranked above (A and B) the minimum value is 6, so C should be assigned a value of 6</p>
  <p>F has a rank of 6, the items ranked above (A, B, C, D, E) the minimum value is 6, so C should be assigned a value of 6</p>
  <p>H has a rank of 8, the items ranked above (A, B, C, D, E, F, G) the minimum value is 4, so H should be assinged a value of 4</p>
  <p>resulting dataframe should look like this</p>
  <pre><code>   A  rank  value
  0  A     1    8.0
  1  B     2    6.0
  2  C     3    6.0
  3  D     4    7.0
  4  E     5    9.0
  5  F     6    6.0
  6  G     7    4.0
  7  H     8    4.0
  </code></pre>
  <p>How can this be achieved with 1 or 2 lines of code?</p>