@classmethod<EOL><INDENT>def from_codes(cls, codes, categories=None, ordered=None, dtype=None):<DEDENT>
dtype = CategoricalDtype._from_values_or_dtype(categories=categories,<EOL>ordered=ordered,<EOL>dtype=dtype)<EOL>if dtype.categories is None:<EOL><INDENT>msg = ("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>raise ValueError(msg)<EOL><DEDENT>codes = np.asarray(codes)  <EOL>if not is_integer_dtype(codes):<EOL><INDENT>msg = "<STR_LIT>"<EOL>if is_float_dtype(codes):<EOL><INDENT>icodes = codes.astype('<STR_LIT>')<EOL>if (icodes == codes).all():<EOL><INDENT>msg = None<EOL>codes = icodes<EOL>warn(("<STR_LIT>"<EOL>"<STR_LIT>"), FutureWarning, stacklevel=<NUM_LIT:2>)<EOL><DEDENT><DEDENT>if msg:<EOL><INDENT>raise ValueError(msg)<EOL><DEDENT><DEDENT>if len(codes) and (<EOL>codes.max() >= len(dtype.categories) or codes.min() < -<NUM_LIT:1>):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>return cls(codes, dtype=dtype, fastpath=True)<EOL>
Make a Categorical type from codes and categories or dtype.

This constructor is useful if you already have codes and
categories/dtype and so do not need the (computation intensive)
factorization step, which is usually done on the constructor.

If your data does not follow this convention, please use the normal
constructor.

Parameters
----------
codes : array-like, integers
    An integer array, where each integer points to a category in
    categories or dtype.categories, or else is -1 for NaN.
categories : index-like, optional
    The categories for the categorical. Items need to be unique.
    If the categories are not given here, then they must be provided
    in `dtype`.
ordered : bool, optional
    Whether or not this categorical is treated as an ordered
    categorical. If not given here or in `dtype`, the resulting
    categorical will be unordered.
dtype : CategoricalDtype or the string "category", optional
    If :class:`CategoricalDtype`, cannot be used together with
    `categories` or `ordered`.

    .. versionadded:: 0.24.0

       When `dtype` is provided, neither `categories` nor `ordered`
       should be provided.

Examples
--------
>>> dtype = pd.CategoricalDtype(['a', 'b'], ordered=True)
>>> pd.Categorical.from_codes(codes=[0, 1, 0, 1], dtype=dtype)
[a, b, a, b]
Categories (2, object): [a < b]