(self, normalize=False, sort=True, ascending=False, bins=None, dropna=True)
return None
Intel Scalable Dataframe Compiler User Guide
    ********************************************

    Pandas API: pandas.Series.value_counts

    Limitations
    -----------
    - Parameters ``normalize`` and ``bins`` are currently unsupported.
    - Parameter ``dropna`` is unsupported for String Series.
    - Elements with the same count might appear in result in a different order than in Pandas.
    - 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_value_counts.py
       :language: python
       :lines: 35-
       :caption: Getting the number of values excluding NaNs
       :name: ex_series_value_counts

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

    .. seealso::

        :ref:`Series.count <pandas.Series.count>`

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

    .. only:: developer
        Test: python -m sdc.runtests -k sdc.tests.test_series.TestSeries.test_series_value_counts*
Intel Scalable Dataframe Compiler User Guide
    ********************************************
Intel Scalable Dataframe Compiler User Guide ********************************************
def hpat_pandas_series_value_counts(self, normalize=False, sort=True, ascending=False, bins=None, dropna=True):
    """
    Intel Scalable Dataframe Compiler User Guide
    ********************************************

    Pandas API: pandas.Series.value_counts

    Limitations
    -----------
    - Parameters ``normalize`` and ``bins`` are currently unsupported.
    - Parameter ``dropna`` is unsupported for String Series.
    - Elements with the same count might appear in result in a different order than in Pandas.
    - 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_value_counts.py
       :language: python
       :lines: 35-
       :caption: Getting the number of values excluding NaNs
       :name: ex_series_value_counts

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

    .. seealso::

        :ref:`Series.count <pandas.Series.count>`

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

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

    _func_name = 'Method value_counts().'

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

    if not isinstance(normalize, (types.Omitted, types.Boolean, bool)) and normalize is True:
        ty_checker.raise_exc(normalize, 'boolean', 'normalize')

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

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

    if not isinstance(bins, (types.Omitted, types.NoneType)) and bins is not None:
        ty_checker.raise_exc(bins, 'boolean', 'bins')

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

    if isinstance(self.data, StringArrayType):
        def hpat_pandas_series_value_counts_str_impl(
                self, normalize=False, sort=True, ascending=False, bins=None, dropna=True):

            value_counts_dict = Dict.empty(
                key_type=types.unicode_type,
                value_type=types.intp
            )

            nan_counts = 0
            for i, value in enumerate(self._data):
                if str_arr_is_na(self._data, i):
                    if not dropna:
                        nan_counts += 1
                    continue

                value_counts_dict[value] = value_counts_dict.get(value, 0) + 1

            need_add_nan_count = not dropna and nan_counts

            values = [key for key in value_counts_dict]
            counts_as_list = [value_counts_dict[key] for key in value_counts_dict.keys()]
            values_len = len(values)

            if need_add_nan_count:
                # append a separate empty string for NaN elements
                values_len += 1
                values.append('')
                counts_as_list.append(nan_counts)

            counts = numpy.asarray(counts_as_list, dtype=numpy.intp)
            indexes_order = numpy.arange(values_len)
            if sort:
                indexes_order = numpy_like.argsort(counts)
                if not ascending:
                    indexes_order = indexes_order[::-1]

            counts_sorted = numpy.take(counts, indexes_order)
            values_sorted_by_count = [values[i] for i in indexes_order]

            # allocate the result index as a StringArray and copy values to it
            result_index = create_str_arr_from_list(values_sorted_by_count)
            if need_add_nan_count:
                # set null bit for StringArray element corresponding to NaN element (was added as last in values)
                index_previous_nan_pos = values_len - 1
                for i in numpy.arange(values_len):
                    if indexes_order[i] == index_previous_nan_pos:
                        str_arr_set_na(result_index, i)
                        break

            return pandas.Series(counts_sorted, index=result_index, name=self._name)

        return hpat_pandas_series_value_counts_str_impl

    elif isinstance(self.dtype, (types.Number, types.Boolean)):

        series_dtype = self.dtype
        def hpat_pandas_series_value_counts_number_impl(
                self, normalize=False, sort=True, ascending=False, bins=None, dropna=True):

            value_counts_dict = Dict.empty(
                key_type=series_dtype,
                value_type=types.intp
            )

            zero_counts = 0
            is_zero_found = False
            for value in self._data:
                if (dropna and numpy.isnan(value)):
                    continue

                # Pandas hash-based value_count_float64 function doesn't distinguish between
                # positive and negative zeros, hence we count zero values separately and store
                # as a key the first zero value found in the Series
                if not value:
                    zero_counts += 1
                    if not is_zero_found:
                        zero_value = value
                        is_zero_found = True
                    continue

                value_counts_dict[value] = value_counts_dict.get(value, 0) + 1

            if zero_counts:
                value_counts_dict[zero_value] = zero_counts

            unique_values = numpy.asarray(
                list(value_counts_dict),
                dtype=self._data.dtype
            )
            value_counts = numpy.asarray(
                [value_counts_dict[key] for key in value_counts_dict],
                dtype=numpy.intp
            )

            indexes_order = numpy.arange(len(value_counts))
            if sort:
                indexes_order = numpy_like.argsort(value_counts)
                if not ascending:
                    indexes_order = indexes_order[::-1]

            sorted_unique_values = numpy.take(unique_values, indexes_order)
            sorted_value_counts = numpy.take(value_counts, indexes_order)

            return pandas.Series(sorted_value_counts, index=sorted_unique_values, name=self._name)

        return hpat_pandas_series_value_counts_number_impl

    return None
def hpat_pandas_series_value_counts ( self , normalize = False , sort = True , ascending = False , bins = None , dropna = True ) : _func_name = 'Method value_counts().' ty_checker = TypeChecker ( 'Method value_counts().' ) ty_checker . check ( self , SeriesType ) if not isinstance ( normalize , ( types . Omitted , types . Boolean , bool ) ) and normalize is True : ty_checker . raise_exc ( normalize , 'boolean' , 'normalize' ) if not isinstance ( sort , ( types . Omitted , types . Boolean , bool ) ) : ty_checker . raise_exc ( sort , 'boolean' , 'sort' ) if not isinstance ( ascending , ( types . Omitted , types . Boolean , bool ) ) : ty_checker . raise_exc ( ascending , 'boolean' , 'ascending' ) if not isinstance ( bins , ( types . Omitted , types . NoneType ) ) and bins is not None : ty_checker . raise_exc ( bins , 'boolean' , 'bins' ) if not isinstance ( dropna , ( types . Omitted , types . Boolean , bool ) ) : ty_checker . raise_exc ( dropna , 'boolean' , 'dropna' ) if isinstance ( self . data , StringArrayType ) : def hpat_pandas_series_value_counts_str_impl ( self , normalize = False , sort = True , ascending = False , bins = None , dropna = True ) : value_counts_dict = Dict . empty ( key_type = types . unicode_type , value_type = types . intp ) nan_counts = 0 for i , value in enumerate ( self . _data ) : if str_arr_is_na ( self . _data , i ) : if not dropna : nan_counts += 1 continue value_counts_dict [ value ] = value_counts_dict . get ( value , 0 ) + 1 need_add_nan_count = not dropna and nan_counts values = [ key for key in value_counts_dict ] counts_as_list = [ value_counts_dict [ key ] for key in value_counts_dict . keys ( ) ] values_len = len ( values ) if need_add_nan_count : # append a separate empty string for NaN elements values_len += 1 values . append ( '' ) counts_as_list . append ( nan_counts ) counts = numpy . asarray ( counts_as_list , dtype = numpy . intp ) indexes_order = numpy . arange ( values_len ) if sort : indexes_order = numpy_like . argsort ( counts ) if not ascending : indexes_order = indexes_order [ : : - 1 ] counts_sorted = numpy . take ( counts , indexes_order ) values_sorted_by_count = [ values [ i ] for i in indexes_order ] # allocate the result index as a StringArray and copy values to it result_index = create_str_arr_from_list ( values_sorted_by_count ) if need_add_nan_count : # set null bit for StringArray element corresponding to NaN element (was added as last in values) index_previous_nan_pos = values_len - 1 for i in numpy . arange ( values_len ) : if indexes_order [ i ] == index_previous_nan_pos : str_arr_set_na ( result_index , i ) break return pandas . Series ( counts_sorted , index = result_index , name = self . _name ) return hpat_pandas_series_value_counts_str_impl elif isinstance ( self . dtype , ( types . Number , types . Boolean ) ) : series_dtype = self . dtype def hpat_pandas_series_value_counts_number_impl ( self , normalize = False , sort = True , ascending = False , bins = None , dropna = True ) : value_counts_dict = Dict . empty ( key_type = series_dtype , value_type = types . intp ) zero_counts = 0 is_zero_found = False for value in self . _data : if ( dropna and numpy . isnan ( value ) ) : continue # Pandas hash-based value_count_float64 function doesn't distinguish between # positive and negative zeros, hence we count zero values separately and store # as a key the first zero value found in the Series if not value : zero_counts += 1 if not is_zero_found : zero_value = value is_zero_found = True continue value_counts_dict [ value ] = value_counts_dict . get ( value , 0 ) + 1 if zero_counts : value_counts_dict [ zero_value ] = zero_counts unique_values = numpy . asarray ( list ( value_counts_dict ) , dtype = self . _data . dtype ) value_counts = numpy . asarray ( [ value_counts_dict [ key ] for key in value_counts_dict ] , dtype = numpy . intp ) indexes_order = numpy . arange ( len ( value_counts ) ) if sort : indexes_order = numpy_like . argsort ( value_counts ) if not ascending : indexes_order = indexes_order [ : : - 1 ] sorted_unique_values = numpy . take ( unique_values , indexes_order ) sorted_value_counts = numpy . take ( value_counts , indexes_order ) return pandas . Series ( sorted_value_counts , index = sorted_unique_values , name = self . _name ) return hpat_pandas_series_value_counts_number_impl return None