docstr: Cast values to specified type
  
  Parameters
  ----------
  values : ndarray or ExtensionArray
  cast_type : np.dtype or ExtensionDtype
     dtype to cast values to
  column : string
      column name - used only for error reporting
  
  Returns
  -------
  converted : ndarray or ExtensionArray
docstr_tok: ["Cast","values","to","specified","type","Parameters","--","--","--","--","--","values",":","ndarray","or","ExtensionArray","cast_type",":","np.dtype","or","ExtensionDtype","dtype","to","cast","values","to","column",":","string","column","name","-","used","only","for","error","reporting","Returns","--","--","--","-","converted",":","ndarray","or","ExtensionArray"]
code: def _cast_types(
      self, values: ArrayLike, cast_type: DtypeObj, column
  ) -> ArrayLike:
      """
      Cast values to specified type
  
      Parameters
      ----------
      values : ndarray or ExtensionArray
      cast_type : np.dtype or ExtensionDtype
         dtype to cast values to
      column : string
          column name - used only for error reporting
  
      Returns
      -------
      converted : ndarray or ExtensionArray
      """
      if isinstance(cast_type, CategoricalDtype):
          known_cats = cast_type.categories is not None
  
          if not is_object_dtype(values.dtype) and not known_cats:
              # TODO: this is for consistency with
              # c-parser which parses all categories
              # as strings
              values = lib.ensure_string_array(
                  values, skipna=False, convert_na_value=False
              )
  
          cats = Index(values).unique().dropna()
          values = Categorical._from_inferred_categories(
              cats,
              cats.get_indexer(values),
              cast_type,
              true_values=self.true_values,
          )
  
      # use the EA's implementation of casting
      elif isinstance(cast_type, ExtensionDtype):
          array_type = cast_type.construct_array_type()
          try:
              if isinstance(cast_type, BooleanDtype):
                  # error: Unexpected keyword argument "true_values" for
                  # "_from_sequence_of_strings" of "ExtensionArray"
                  return array_type._from_sequence_of_strings(  # type: ignore[call-arg]  # noqa:E501
                      values,
                      dtype=cast_type,
                      true_values=self.true_values,
                      false_values=self.false_values,
                  )
              else:
                  return array_type._from_sequence_of_strings(
                      values, dtype=cast_type
                  )
          except NotImplementedError as err:
              raise NotImplementedError(
                  f"Extension Array: {array_type} must implement "
                  "_from_sequence_of_strings in order to be used in parser methods"
              ) from err
  
      elif isinstance(values, ExtensionArray):
          values = values.astype(cast_type, copy=False)
      elif issubclass(cast_type.type, str):
          # TODO: why skipna=True here and False above? some tests depend
          #  on it here, but nothing fails if we change it above
          #  (as no tests get there as of 2022-12-06)
          values = lib.ensure_string_array(
              values, skipna=True, convert_na_value=False
          )
      else:
          try:
              values = astype_array(values, cast_type, copy=True)
          except ValueError as err:
              raise ValueError(
                  f"Unable to convert column {column} to type {cast_type}"
              ) from err
      return values
  
imports: from __future__ import annotations
  from collections import defaultdict
  from copy import copy
  import csv
  import datetime
  from enum import Enum
  import itertools
  from typing import TYPE_CHECKING, Any, Callable, Hashable, Iterable, List, Mapping, Sequence, Tuple, cast, final, overload
  import warnings
  import numpy
  from pandas._libs import lib, parsers
  import pandas._libs.ops
  from pandas._libs.parsers import STR_NA_VALUES
  from pandas._libs.tslibs import parsing
  from pandas._typing import ArrayLike, DtypeArg, DtypeObj, Scalar
  from pandas.compat._optional import import_optional_dependency
  from pandas.errors import ParserError, ParserWarning
  from pandas.util._exceptions import find_stack_level
  from pandas.core.dtypes.astype import astype_array
  from pandas.core.dtypes.common import ensure_object, is_bool_dtype, is_dict_like, is_dtype_equal, is_extension_array_dtype, is_float_dtype, is_integer, is_integer_dtype, is_list_like, is_object_dtype, is_scalar, is_string_dtype, pandas_dtype
  from pandas.core.dtypes.dtypes import CategoricalDtype, ExtensionDtype
  from pandas.core.dtypes.missing import isna
  from pandas import ArrowDtype, DatetimeIndex, StringDtype
  from pandas.core import algorithms
  from pandas.core.arrays import ArrowExtensionArray, BooleanArray, Categorical, ExtensionArray, FloatingArray, IntegerArray
  from pandas.core.arrays.boolean import BooleanDtype
  from pandas.core.indexes.api import Index, MultiIndex, default_index, ensure_index_from_sequences
  from pandas.core.series import Series
  from pandas.core.tools import datetimes
  from pandas.io.common import is_potential_multi_index
label_desc: Use image node_id 16 for calling the ParserBase obj's underlying member method code with example usage: obj._cast_types(values, cast_type, column) and returns: values, array_type, array_type