def astype(self, dtype, copy=True):
    '\n        Coerce this type to another dtype\n\n        Parameters\n        ----------\n        dtype : numpy dtype or pandas type\n        copy : bool, default True\n            By default, astype always returns a newly allocated object.\n            If copy is set to False and dtype is categorical, the original\n            object is returned.\n\n            .. versionadded:: 0.19.0\n\n        '
    if is_categorical_dtype(dtype):
        dtype = self.dtype.update_dtype(dtype)
        self = (self.copy() if copy else self)
        if (dtype == self.dtype):
            return self
        return self._set_dtype(dtype)
    return np.array(self, dtype=dtype, copy=copy)
Coerce this type to another dtype

Parameters
----------
dtype : numpy dtype or pandas type
copy : bool, default True
    By default, astype always returns a newly allocated object.
    If copy is set to False and dtype is categorical, the original
    object is returned.

    .. versionadded:: 0.19.0
def astype(self, dtype, copy=True):
    '\n        Coerce this type to another dtype\n\n        Parameters\n        ----------\n        dtype : numpy dtype or pandas type\n        copy : bool, default True\n            By default, astype always returns a newly allocated object.\n            If copy is set to False and dtype is categorical, the original\n            object is returned.\n\n            .. versionadded:: 0.19.0\n\n        '
    if is_categorical_dtype(dtype):
        dtype = self.dtype.update_dtype(dtype)
        self = (self.copy() if copy else self)
        if (dtype == self.dtype):
            return self
        return self._set_dtype(dtype)
    return np.array(self, dtype=dtype, copy=copy)