SeriesGroupBy.
value_counts
Compute group sizes.
Sort by frequencies.
Sort in ascending order.
Don’t include counts of NaN.
See also
pyspark.pandas.Series.groupby
pyspark.pandas.DataFrame.groupby
Examples
>>> df = ps.DataFrame({'A': [1, 2, 2, 3, 3, 3], ... 'B': [1, 1, 2, 3, 3, np.nan]}, ... columns=['A', 'B']) >>> df A B 0 1 1.0 1 2 1.0 2 2 2.0 3 3 3.0 4 3 3.0 5 3 NaN
>>> df.groupby('A')['B'].value_counts().sort_index() A B 1 1.0 1 2 1.0 1 2.0 1 3 3.0 2 Name: B, dtype: int64
Don’t include counts of NaN when dropna is False.
>>> df.groupby('A')['B'].value_counts( ... dropna=False).sort_index() A B 1 1.0 1 2 1.0 1 2.0 1 3 3.0 2 NaN 1 Name: B, dtype: int64