title: How to rank distinctly for each row in pandas.DataFrame
body: <h2>What I have</h2>
  
  <p>a user-user similarity matrix that some rows have duplicated value and <code>NaN</code> </p>
  
  <pre><code>userId  316       320       359       370       910
  userId                                             
  316     1.0  0.500000  0.500000  0.500000       NaN
  320     0.5  1.000000  0.242837  0.019035  0.031737
  359     0.5  0.242837  1.000000  0.357620  0.175914
  370     0.5  0.019035  0.357620  1.000000  0.317371
  910     NaN  0.031737  0.175914  0.317371  1.000000
  </code></pre>
  
  <h2>What I want</h2>
  
  <p>I want rank the simirity for each row distinctly. Like so:</p>
  
  <pre><code>userId  316  320  359  370  910
  userId                         
  316       1    2    3    4   NaN
  320       2    1    3    5    1
  359       2    4    1    3    5
  370       2    5    3    1    4
  910      NaN   4    3    2    1
  </code></pre>
  
  <p>The rank between the same value is not important. But it needs to be a distinct value. And <code>NaN</code>must be keeped.</p>
  
  <h2>What I tired</h2>
  
  <p>I tried <code>df.rank(ascending =False,axis = 1)</code> (<a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.rank.html" rel="nofollow noreferrer">doc</a>), which failed to give me a distinct value of rank.<br>
  I also tried <code>scipy.stats.rankdata</code> (<a href="https://docs.scipy.org/doc/scipy-0.16.0/reference/generated/scipy.stats.rankdata.html" rel="nofollow noreferrer">doc</a>), but it can't keep <code>NaN</code>.  </p>