(self, dtype, copy=True, errors='raise')
Intel Scalable Dataframe Compiler User Guide
    ********************************************

    Pandas API: pandas.Series.astype

    Limitations
    -----------
    - Parameter ``copy`` is supported only with default value ``True``.

    Examples
    --------
    .. literalinclude:: ../../../examples/series/series_astype.py
       :language: python
       :lines: 36-
       :caption: Cast a pandas object to a specified dtype.
       :name: ex_series_astype

    .. command-output:: python ./series/series_astype.py
       :cwd: ../../../examples

    .. seealso::

        `pandas.to_datetime
        <https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_datetime.html#pandas.to_datetime>`_
            Convert argument to datetime.

        `pandas.to_timedelta
        <https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_timedelta.html#pandas.to_timedelta>`_
            Convert argument to timedelta.

        `pandas.to_numeric
        <https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_numeric.html#pandas.to_numeric>`_
            Convert argument to a numeric type.

        `numpy.ndarray.astype
        <https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.astype.html#numpy.ndarray.astype>`_
            Copy of the array, cast to a specified type.

    Intel Scalable Dataframe Compiler Developer Guide
    *************************************************
    Pandas Series method :meth:`pandas.Series.astype` implementation.

    .. only:: developer
        Test: python -m sdc.runtests -k sdc.tests.test_series.TestSeries.test_series_astype*
Intel Scalable Dataframe Compiler User Guide
    ********************************************
Intel Scalable Dataframe Compiler User Guide ********************************************
def hpat_pandas_series_astype(self, dtype, copy=True, errors='raise'):
    """
    Intel Scalable Dataframe Compiler User Guide
    ********************************************

    Pandas API: pandas.Series.astype

    Limitations
    -----------
    - Parameter ``copy`` is supported only with default value ``True``.

    Examples
    --------
    .. literalinclude:: ../../../examples/series/series_astype.py
       :language: python
       :lines: 36-
       :caption: Cast a pandas object to a specified dtype.
       :name: ex_series_astype

    .. command-output:: python ./series/series_astype.py
       :cwd: ../../../examples

    .. seealso::

        `pandas.to_datetime
        <https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_datetime.html#pandas.to_datetime>`_
            Convert argument to datetime.

        `pandas.to_timedelta
        <https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_timedelta.html#pandas.to_timedelta>`_
            Convert argument to timedelta.

        `pandas.to_numeric
        <https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_numeric.html#pandas.to_numeric>`_
            Convert argument to a numeric type.

        `numpy.ndarray.astype
        <https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.astype.html#numpy.ndarray.astype>`_
            Copy of the array, cast to a specified type.

    Intel Scalable Dataframe Compiler Developer Guide
    *************************************************
    Pandas Series method :meth:`pandas.Series.astype` implementation.

    .. only:: developer
        Test: python -m sdc.runtests -k sdc.tests.test_series.TestSeries.test_series_astype*
    """

    _func_name = 'Method astype().'

    ty_checker = TypeChecker(_func_name)
    ty_checker.check(self, SeriesType)

    if not isinstance(copy, (types.Omitted, bool, types.Boolean)):
        ty_checker.raise_exc(copy, 'bool', 'copy')

    if not (isinstance(dtype, (types.functions.NumberClass, types.Function, types.StringLiteral))):
        return None

    if (not isinstance(errors, (types.Omitted, str, types.UnicodeType, types.StringLiteral)) and
        errors in ('raise', 'ignore')):
        ty_checker.raise_exc(errors, 'str', 'errors')

    # Return npytypes.Array from npytypes.Array for astype(types.functions.NumberClass), example - astype(np.int64)
    # Return npytypes.Array from npytypes.Array for astype(types.StringLiteral), example - astype('int64')
    def hpat_pandas_series_astype_numba_impl(self, dtype, copy=True, errors='raise'):
        return pandas.Series(data=numpy_like.astype_no_inline(self._data, dtype), index=self._index, name=self._name)

    # Return self
    def hpat_pandas_series_astype_no_modify_impl(self, dtype, copy=True, errors='raise'):
        return pandas.Series(data=self._data, index=self._index, name=self._name)

    str_check = ((isinstance(dtype, types.Function) and dtype.typing_key == str) or
                 (isinstance(dtype, types.StringLiteral) and dtype.literal_value == 'str'))

    # Needs Numba astype impl support converting unicode_type to NumberClass and other types
    if isinstance(self.data, StringArrayType):
        if not str_check:
            if isinstance(dtype, types.functions.NumberClass) and errors == 'raise':
                raise TypingError(f'Needs Numba astype impl support converting unicode_type to {dtype}')
            if isinstance(dtype, types.StringLiteral) and errors == 'raise':
                try:
                    literal_value = numpy.dtype(dtype.literal_value)
                except TypeError:
                    pass  # Will raise the exception later
                else:
                    raise TypingError(f'Needs Numba astype impl support converting unicode_type to {literal_value}')
        else:
            return hpat_pandas_series_astype_no_modify_impl

    data_narr = isinstance(self.data, types.npytypes.Array)
    dtype_num_liter = isinstance(dtype, (types.functions.NumberClass, types.StringLiteral))

    if data_narr and dtype_num_liter or str_check:
        return hpat_pandas_series_astype_numba_impl

    if errors == 'raise':
        raise TypingError(f'{_func_name} The object must be a supported type. Given dtype: {dtype}')
    else:
        return hpat_pandas_series_astype_no_modify_impl
def hpat_pandas_series_astype ( self , dtype , copy = True , errors = 'raise' ) : _func_name = 'Method astype().' ty_checker = TypeChecker ( _func_name ) ty_checker . check ( self , SeriesType ) if not isinstance ( copy , ( types . Omitted , bool , types . Boolean ) ) : ty_checker . raise_exc ( copy , 'bool' , 'copy' ) if not ( isinstance ( dtype , ( types . functions . NumberClass , types . Function , types . StringLiteral ) ) ) : return None if ( not isinstance ( errors , ( types . Omitted , str , types . UnicodeType , types . StringLiteral ) ) and errors in ( 'raise' , 'ignore' ) ) : ty_checker . raise_exc ( errors , 'str' , 'errors' ) # Return npytypes.Array from npytypes.Array for astype(types.functions.NumberClass), example - astype(np.int64) # Return npytypes.Array from npytypes.Array for astype(types.StringLiteral), example - astype('int64') def hpat_pandas_series_astype_numba_impl ( self , dtype , copy = True , errors = 'raise' ) : return pandas . Series ( data = numpy_like . astype_no_inline ( self . _data , dtype ) , index = self . _index , name = self . _name ) # Return self def hpat_pandas_series_astype_no_modify_impl ( self , dtype , copy = True , errors = 'raise' ) : return pandas . Series ( data = self . _data , index = self . _index , name = self . _name ) str_check = ( ( isinstance ( dtype , types . Function ) and dtype . typing_key == str ) or ( isinstance ( dtype , types . StringLiteral ) and dtype . literal_value == 'str' ) ) # Needs Numba astype impl support converting unicode_type to NumberClass and other types if isinstance ( self . data , StringArrayType ) : if not str_check : if isinstance ( dtype , types . functions . NumberClass ) and errors == 'raise' : raise TypingError ( f'Needs Numba astype impl support converting unicode_type to {dtype}' ) if isinstance ( dtype , types . StringLiteral ) and errors == 'raise' : try : literal_value = numpy . dtype ( dtype . literal_value ) except TypeError : pass # Will raise the exception later else : raise TypingError ( f'Needs Numba astype impl support converting unicode_type to {literal_value}' ) else : return hpat_pandas_series_astype_no_modify_impl data_narr = isinstance ( self . data , types . npytypes . Array ) dtype_num_liter = isinstance ( dtype , ( types . functions . NumberClass , types . StringLiteral ) ) if data_narr and dtype_num_liter or str_check : return hpat_pandas_series_astype_numba_impl if errors == 'raise' : raise TypingError ( f'{_func_name} The object must be a supported type. Given dtype: {dtype}' ) else : return hpat_pandas_series_astype_no_modify_impl