pandas.core.groupby.SeriesGroupBy.nunique#
- SeriesGroupBy.nunique(dropna=True)[source]#
Return number of unique elements in the group.
- Parameters:
- dropnabool, default True
Don’t include NaN in the counts.
- Returns:
- Series
Number of unique values within each group.
See also
core.resample.Resampler.nunique
Method nunique for Resampler.
Examples
>>> lst = ["a", "a", "b", "b"] >>> ser = pd.Series([1, 2, 3, 3], index=lst) >>> ser a 1 a 2 b 3 b 3 dtype: int64 >>> ser.groupby(level=0).nunique() a 2 b 1 dtype: int64