def astype(self, dtype, copy=True, errors='<STR_LIT>', **kwargs):
if is_dict_like(dtype):<EOL><INDENT>if self.ndim == <NUM_LIT:1>:  <EOL><INDENT>if len(dtype) > <NUM_LIT:1> or self.name not in dtype:<EOL><INDENT>raise KeyError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>new_type = dtype[self.name]<EOL>return self.astype(new_type, copy, errors, **kwargs)<EOL><DEDENT>elif self.ndim > <NUM_LIT:2>:<EOL><INDENT>raise NotImplementedError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL><DEDENT>for col_name in dtype.keys():<EOL><INDENT>if col_name not in self:<EOL><INDENT>raise KeyError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>results = []<EOL>for col_name, col in self.iteritems():<EOL><INDENT>if col_name in dtype:<EOL><INDENT>results.append(col.astype(dtype=dtype[col_name], copy=copy,<EOL>errors=errors, **kwargs))<EOL><DEDENT>else:<EOL><INDENT>results.append(results.append(col.copy() if copy else col))<EOL><DEDENT><DEDENT><DEDENT>elif is_extension_array_dtype(dtype) and self.ndim > <NUM_LIT:1>:<EOL><INDENT>results = (self.iloc[:, i].astype(dtype, copy=copy)<EOL>for i in range(len(self.columns)))<EOL><DEDENT>else:<EOL><INDENT>new_data = self._data.astype(dtype=dtype, copy=copy, errors=errors,<EOL>**kwargs)<EOL>return self._constructor(new_data).__finalize__(self)<EOL><DEDENT>result = pd.concat(results, axis=<NUM_LIT:1>, copy=False)<EOL>result.columns = self.columns<EOL>return result<EOL>
Cast a pandas object to a specified dtype ``dtype``.

Parameters
----------
dtype : data type, or dict of column name -> data type
    Use a numpy.dtype or Python type to cast entire pandas object to
    the same type. Alternatively, use {col: dtype, ...}, where col is a
    column label and dtype is a numpy.dtype or Python type to cast one
    or more of the DataFrame's columns to column-specific types.
copy : bool, default True
    Return a copy when ``copy=True`` (be very careful setting
    ``copy=False`` as changes to values then may propagate to other
    pandas objects).
errors : {'raise', 'ignore'}, default 'raise'
    Control raising of exceptions on invalid data for provided dtype.

    - ``raise`` : allow exceptions to be raised
    - ``ignore`` : suppress exceptions. On error return original object

    .. versionadded:: 0.20.0

kwargs : keyword arguments to pass on to the constructor

Returns
-------
casted : same type as caller

See Also
--------
to_datetime : Convert argument to datetime.
to_timedelta : Convert argument to timedelta.
to_numeric : Convert argument to a numeric type.
numpy.ndarray.astype : Cast a numpy array to a specified type.

Examples
--------
>>> ser = pd.Series([1, 2], dtype='int32')
>>> ser
0    1
1    2
dtype: int32
>>> ser.astype('int64')
0    1
1    2
dtype: int64

Convert to categorical type:

>>> ser.astype('category')
0    1
1    2
dtype: category
Categories (2, int64): [1, 2]

Convert to ordered categorical type with custom ordering:

>>> cat_dtype = pd.api.types.CategoricalDtype(
...                     categories=[2, 1], ordered=True)
>>> ser.astype(cat_dtype)
0    1
1    2
dtype: category
Categories (2, int64): [2 < 1]

Note that using ``copy=False`` and changing data on a new
pandas object may propagate changes:

>>> s1 = pd.Series([1,2])
>>> s2 = s1.astype('int64', copy=False)
>>> s2[0] = 10
>>> s1  # note that s1[0] has changed too
0    10
1     2
dtype: int64