def _values_for_rank(self):
from pandas import Series<EOL>if self.ordered:<EOL><INDENT>values = self.codes<EOL>mask = values == -<NUM_LIT:1><EOL>if mask.any():<EOL><INDENT>values = values.astype('<STR_LIT>')<EOL>values[mask] = np.nan<EOL><DEDENT><DEDENT>elif self.categories.is_numeric():<EOL><INDENT>values = np.array(self)<EOL><DEDENT>else:<EOL><INDENT>values = np.array(<EOL>self.rename_categories(Series(self.categories).rank().values)<EOL>)<EOL><DEDENT>return values<EOL>
For correctly ranking ordered categorical data. See GH#15420

Ordered categorical data should be ranked on the basis of
codes with -1 translated to NaN.

Returns
-------
numpy.array