bigframes.pandas.Index.value_counts#

Index.value_counts(normalize: bool = False, sort: bool = True, ascending: bool = False, *, dropna: bool = True)[source]#

Return a Series containing counts of unique values.

The resulting object will be in descending order so that the first element is the most frequently-occurring element. Excludes NA values by default.

Examples:

>>> index = bpd.Index([3, 1, 2, 3, 4, np.nan])
>>> index.value_counts()
3.0    2
1.0    1
2.0    1
4.0    1
Name: count, dtype: Int64

With normalize set to True, returns the relative frequency by dividing all values by the sum of values.

>>> s = bpd.Series([3, 1, 2, 3, 4, np.nan])
>>> s.value_counts(normalize=True)
3.0    0.4
1.0    0.2
2.0    0.2
4.0    0.2
Name: proportion, dtype: Float64

dropna

With dropna set to False we can also see NaN index values.

>>> s.value_counts(dropna=False)
3.0     2
1.0     1
2.0     1
4.0     1
<NA>    1
Name: count, dtype: Int64
Parameters:
  • normalize (bool, default False) – If True, then the object returned will contain the relative frequencies of the unique values.

  • sort (bool, default True) – Sort by frequencies.

  • ascending (bool, default False) – Sort in ascending order.

  • dropna (bool, default True) – Don’t include counts of NaN.

Returns:

bigframes.pandas.Series