def _cast_types(self, values, cast_type, column):
if is_categorical_dtype(cast_type):<EOL><INDENT>known_cats = (isinstance(cast_type, CategoricalDtype) and<EOL>cast_type.categories is not None)<EOL>if not is_object_dtype(values) and not known_cats:<EOL><INDENT>values = astype_nansafe(values, str)<EOL><DEDENT>cats = Index(values).unique().dropna()<EOL>values = Categorical._from_inferred_categories(<EOL>cats, cats.get_indexer(values), cast_type,<EOL>true_values=self.true_values)<EOL><DEDENT>elif is_extension_array_dtype(cast_type):<EOL><INDENT>cast_type = pandas_dtype(cast_type)<EOL>array_type = cast_type.construct_array_type()<EOL>try:<EOL><INDENT>return array_type._from_sequence_of_strings(values,<EOL>dtype=cast_type)<EOL><DEDENT>except NotImplementedError:<EOL><INDENT>raise NotImplementedError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(ea=array_type))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>values = astype_nansafe(values, cast_type,<EOL>copy=True, skipna=True)<EOL><DEDENT>except ValueError:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(<EOL>column=column, cast_type=cast_type))<EOL><DEDENT><DEDENT>return values<EOL>
Cast values to specified type

Parameters
----------
values : ndarray
cast_type : string or np.dtype
   dtype to cast values to
column : string
    column name - used only for error reporting

Returns
-------
converted : ndarray