def _values_for_rank(self):
    '\n        For correctly ranking ordered categorical data. See GH#15420\n\n        Ordered categorical data should be ranked on the basis of\n        codes with -1 translated to NaN.\n\n        Returns\n        -------\n        numpy array\n\n        '
    from pandas import Series
    if self.ordered:
        values = self.codes
        mask = (values == (- 1))
        if mask.any():
            values = values.astype('float64')
            values[mask] = np.nan
    elif self.categories.is_numeric():
        values = np.array(self)
    else:
        values = np.array(self.rename_categories(Series(self.categories).rank().values))
    return values
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
def _values_for_rank(self):
    '\n        For correctly ranking ordered categorical data. See GH#15420\n\n        Ordered categorical data should be ranked on the basis of\n        codes with -1 translated to NaN.\n\n        Returns\n        -------\n        numpy array\n\n        '
    from pandas import Series
    if self.ordered:
        values = self.codes
        mask = (values == (- 1))
        if mask.any():
            values = values.astype('float64')
            values[mask] = np.nan
    elif self.categories.is_numeric():
        values = np.array(self)
    else:
        values = np.array(self.rename_categories(Series(self.categories).rank().values))
    return values