(self, periods=1, fill_method='pad', limit=None, freq=None)
return hpat_pandas_series_pct_change_impl
Intel Scalable Dataframe Compiler User Guide
    ********************************************

    Pandas API: pandas.Series.pct_change

    Limitations
    -----------
    - Parameters limit, freq are currently unsupported by Intel Scalable Dataframe Compiler
    - This function may reveal slower performance than Pandas* on user system. Users should exercise a tradeoff
    between staying in JIT-region with that function or going back to interpreter mode.

    Examples
    --------
    .. literalinclude:: ../../../examples/series/series_pct_change.py
       :language: python
       :lines: 36-
       :caption: Percentage change between the current and a prior element.
       :name: ex_series_pct_change

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

    .. seealso::

        :ref:`Series.diff <pandas.Series.diff>`
            Compute the difference of two elements in a Series.

        :ref:`DataFrame.diff <pandas.DataFrame.diff>`
            Compute the difference of two elements in a DataFrame.

        :ref:`Series.shift <pandas.Series.shift>`
            Shift the index by some number of periods.

        :ref:`DataFrame.shift <pandas.DataFrame.shift>`
            Shift the index by some number of periods.

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

    .. only:: developer
        Test: python -m sdc.runtests -k sdc.tests.test_series.TestSeries.test_series_pct_change
Intel Scalable Dataframe Compiler User Guide
    ********************************************
Intel Scalable Dataframe Compiler User Guide ********************************************
def hpat_pandas_series_pct_change(self, periods=1, fill_method='pad', limit=None, freq=None):
    """
    Intel Scalable Dataframe Compiler User Guide
    ********************************************

    Pandas API: pandas.Series.pct_change

    Limitations
    -----------
    - Parameters limit, freq are currently unsupported by Intel Scalable Dataframe Compiler
    - This function may reveal slower performance than Pandas* on user system. Users should exercise a tradeoff
    between staying in JIT-region with that function or going back to interpreter mode.

    Examples
    --------
    .. literalinclude:: ../../../examples/series/series_pct_change.py
       :language: python
       :lines: 36-
       :caption: Percentage change between the current and a prior element.
       :name: ex_series_pct_change

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

    .. seealso::

        :ref:`Series.diff <pandas.Series.diff>`
            Compute the difference of two elements in a Series.

        :ref:`DataFrame.diff <pandas.DataFrame.diff>`
            Compute the difference of two elements in a DataFrame.

        :ref:`Series.shift <pandas.Series.shift>`
            Shift the index by some number of periods.

        :ref:`DataFrame.shift <pandas.DataFrame.shift>`
            Shift the index by some number of periods.

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

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

    ty_checker = TypeChecker('Method pct_change().')
    ty_checker.check(self, SeriesType)

    if not isinstance(self.data.dtype, types.Number):
        ty_checker.raise_exc(self.data.dtype, 'number', 'self.data')

    if not isinstance(periods, (types.Integer, types.Omitted)):
        ty_checker.raise_exc(periods, 'int64', 'periods')

    if not isinstance(fill_method, (str, types.UnicodeType, types.StringLiteral, types.NoneType, types.Omitted)):
        ty_checker.raise_exc(fill_method, 'string', 'fill_method')

    if not isinstance(limit, (types.Omitted, types.NoneType)):
        ty_checker.raise_exc(limit, 'None', 'limit')

    if not isinstance(freq, (types.Omitted, types.NoneType)):
        ty_checker.raise_exc(freq, 'None', 'freq')

    def hpat_pandas_series_pct_change_impl(self, periods=1, fill_method='pad', limit=None, freq=None):
        if not (fill_method is None or fill_method in ['pad', 'ffill', 'backfill', 'bfill']):
            raise ValueError(
                "Method pct_change(). Unsupported parameter. The function uses fill_method pad (ffill) or backfill (bfill) or None.")
        local_series = self.copy()
        if fill_method is not None:
            # replacement method fillna for given method
            # =========================================
            # Example:
            # s = [1.1, 0.3, np.nan, 1, np.inf, 0, 1.1, np.nan, 2.2, np.inf, 2, 2]
            # result = [1.1, 0.3, 0.3, 1, inf, 0, 1.1, 1.1, 2.2, inf, 2, 2]
            # ==========================================
            for i in range(len(local_series._data)):
                # check each element on numpy.nan
                if numpy.isnan(local_series._data[i]):
                    if fill_method in ['pad', 'ffill']:
                        # if it first element is nan, element will be is nan
                        # if it not first element, element will be is nearest is not nan element
                        # take a step back while will not find is not nan element
                        # if before the first element you did not find one, the element will be equal nan
                        if i == 0:
                            local_series._data[i] = numpy.nan
                        else:
                            k = 1
                            while numpy.isnan(local_series._data[i - k]):
                                if i - k == 0:
                                    local_series._data[i] = numpy.nan
                                    break
                                k += 1
                            local_series._data[i] = local_series._data[i - k]
                    elif fill_method in ['backfill', 'bfill']:
                        # if it last element is nan, element will be is nan
                        # if it not last element, element will be is nearest is not nan element
                        # take a step front while will not find is not nan element
                        # if before the last element you did not find one, the element will be equal nan
                        if i == len(local_series._data)-1:
                            local_series._data[i] = numpy.nan
                        else:
                            k = 1
                            while numpy.isnan(local_series._data[i + k]):
                                if i + k == len(local_series._data) - 1:
                                    local_series._data[i] = numpy.nan
                                    break
                                k += 1
                            local_series._data[i] = local_series._data[i + k]
        rshift = local_series.shift(periods=periods, freq=freq)
        rdiv = local_series.div(rshift)
        result = rdiv._data - 1
        return pandas.Series(result)

    return hpat_pandas_series_pct_change_impl
def hpat_pandas_series_pct_change ( self , periods = 1 , fill_method = 'pad' , limit = None , freq = None ) : ty_checker = TypeChecker ( 'Method pct_change().' ) ty_checker . check ( self , SeriesType ) if not isinstance ( self . data . dtype , types . Number ) : ty_checker . raise_exc ( self . data . dtype , 'number' , 'self.data' ) if not isinstance ( periods , ( types . Integer , types . Omitted ) ) : ty_checker . raise_exc ( periods , 'int64' , 'periods' ) if not isinstance ( fill_method , ( str , types . UnicodeType , types . StringLiteral , types . NoneType , types . Omitted ) ) : ty_checker . raise_exc ( fill_method , 'string' , 'fill_method' ) if not isinstance ( limit , ( types . Omitted , types . NoneType ) ) : ty_checker . raise_exc ( limit , 'None' , 'limit' ) if not isinstance ( freq , ( types . Omitted , types . NoneType ) ) : ty_checker . raise_exc ( freq , 'None' , 'freq' ) def hpat_pandas_series_pct_change_impl ( self , periods = 1 , fill_method = 'pad' , limit = None , freq = None ) : if not ( fill_method is None or fill_method in [ 'pad' , 'ffill' , 'backfill' , 'bfill' ] ) : raise ValueError ( "Method pct_change(). Unsupported parameter. The function uses fill_method pad (ffill) or backfill (bfill) or None." ) local_series = self . copy ( ) if fill_method is not None : # replacement method fillna for given method # ========================================= # Example: # s = [1.1, 0.3, np.nan, 1, np.inf, 0, 1.1, np.nan, 2.2, np.inf, 2, 2] # result = [1.1, 0.3, 0.3, 1, inf, 0, 1.1, 1.1, 2.2, inf, 2, 2] # ========================================== for i in range ( len ( local_series . _data ) ) : # check each element on numpy.nan if numpy . isnan ( local_series . _data [ i ] ) : if fill_method in [ 'pad' , 'ffill' ] : # if it first element is nan, element will be is nan # if it not first element, element will be is nearest is not nan element # take a step back while will not find is not nan element # if before the first element you did not find one, the element will be equal nan if i == 0 : local_series . _data [ i ] = numpy . nan else : k = 1 while numpy . isnan ( local_series . _data [ i - k ] ) : if i - k == 0 : local_series . _data [ i ] = numpy . nan break k += 1 local_series . _data [ i ] = local_series . _data [ i - k ] elif fill_method in [ 'backfill' , 'bfill' ] : # if it last element is nan, element will be is nan # if it not last element, element will be is nearest is not nan element # take a step front while will not find is not nan element # if before the last element you did not find one, the element will be equal nan if i == len ( local_series . _data ) - 1 : local_series . _data [ i ] = numpy . nan else : k = 1 while numpy . isnan ( local_series . _data [ i + k ] ) : if i + k == len ( local_series . _data ) - 1 : local_series . _data [ i ] = numpy . nan break k += 1 local_series . _data [ i ] = local_series . _data [ i + k ] rshift = local_series . shift ( periods = periods , freq = freq ) rdiv = local_series . div ( rshift ) result = rdiv . _data - 1 return pandas . Series ( result ) return hpat_pandas_series_pct_change_impl