docstr: Cast to an ExtensionArray or NumPy array with dtype 'dtype'.
  
  Parameters
  ----------
  dtype : str or dtype
      Typecode or data-type to which the array is cast.
  
  copy : bool, default True
      Whether to copy the data, even if not necessary. If False,
      a copy is made only if the old dtype does not match the
      new dtype.
  
  Returns
  -------
  array : ExtensionArray or ndarray
      ExtensionArray or NumPy ndarray with 'dtype' for its dtype.
docstr_tok: ["Cast","to","an","ExtensionArray","or","NumPy","array","with","dtype","'dtype","'",".","Parameters","--","--","--","--","--","dtype",":","str","or","dtype","Typecode","or","data-type","to","which","the","array","is","cast",".","copy",":","bool",",","default","True","Whether","to","copy","the","data",",","even","if","not","necessary",".","If","False",",","a","copy","is","made","only","if","the","old","dtype","does","not","match","the","new","dtype",".","Returns","--","--","--","-","array",":","ExtensionArray","or","ndarray","ExtensionArray","or","NumPy","ndarray","with","'dtype","'","for","its","dtype","."]
code: def astype(self, dtype, copy=True):
      """
      Cast to an ExtensionArray or NumPy array with dtype 'dtype'.
  
      Parameters
      ----------
      dtype : str or dtype
          Typecode or data-type to which the array is cast.
  
      copy : bool, default True
          Whether to copy the data, even if not necessary. If False,
          a copy is made only if the old dtype does not match the
          new dtype.
  
      Returns
      -------
      array : ExtensionArray or ndarray
          ExtensionArray or NumPy ndarray with 'dtype' for its dtype.
      """
      dtype = pandas_dtype(dtype)
      if is_interval_dtype(dtype):
          if dtype == self.dtype:
              return self.copy() if copy else self
  
          # need to cast to different subtype
          try:
              new_left = self.left.astype(dtype.subtype)
              new_right = self.right.astype(dtype.subtype)
          except TypeError:
              msg = (
                  "Cannot convert {dtype} to {new_dtype}; subtypes are "
                  "incompatible"
              )
              raise TypeError(
                  msg.format(dtype=self.dtype, new_dtype=dtype)
              )
          return self._shallow_copy(new_left, new_right)
      elif is_categorical_dtype(dtype):
          return Categorical(np.asarray(self))
      # TODO: This try/except will be repeated.
      try:
          return np.asarray(self).astype(dtype, copy=copy)
      except (TypeError, ValueError):
          msg = "Cannot cast {name} to dtype {dtype}"
          raise TypeError(
              msg.format(name=type(self).__name__, dtype=dtype)
          )
  
imports: from operator import le, lt
  import textwrap
  import numpy
  from pandas._libs.interval import Interval, IntervalMixin, intervals_to_interval_bounds
  from pandas.compat import add_metaclass
  from pandas.compat.numpy import function
  from pandas.util._decorators import Appender
  from pandas.util._doctools import _WritableDoc
  from pandas.core.dtypes.cast import maybe_convert_platform
  from pandas.core.dtypes.common import is_categorical_dtype, is_datetime64_any_dtype, is_float_dtype, is_integer_dtype, is_interval, is_interval_dtype, is_scalar, is_string_dtype, is_timedelta64_dtype, pandas_dtype
  from pandas.core.dtypes.dtypes import IntervalDtype
  from pandas.core.dtypes.generic import ABCDatetimeIndex, ABCInterval, ABCIntervalIndex, ABCPeriodIndex, ABCSeries
  from pandas.core.dtypes.missing import isna, notna
  from pandas.core.arrays.base import ExtensionArray, _extension_array_shared_docs
  from pandas.core.arrays.categorical import Categorical
  import pandas.core.common
  from pandas.core.config import get_option
  from pandas.core.indexes.base import Index, ensure_index
label_desc: Use image node_id 15 for calling the IntervalArray obj's underlying member method code with example usage: obj.astype(dtype, copy) and returns: self, np, unknown, Categorical