@classmethod<EOL><INDENT>def _create_categorical(cls, data, dtype=None):<DEDENT>
if (isinstance(data, (cls, ABCSeries)) and<EOL>is_categorical_dtype(data)):<EOL><INDENT>data = data.values<EOL><DEDENT>if not isinstance(data, ABCCategorical):<EOL><INDENT>return Categorical(data, dtype=dtype)<EOL><DEDENT>if isinstance(dtype, CategoricalDtype) and dtype != data.dtype:<EOL><INDENT>data = data._set_dtype(dtype)<EOL><DEDENT>return data<EOL>
*this is an internal non-public method*

create the correct categorical from data and the properties

Parameters
----------
data : data for new Categorical
dtype : CategoricalDtype, defaults to existing

Returns
-------
Categorical