xorbits.pandas.groupby.SeriesGroupBy.nunique#

SeriesGroupBy.nunique(**kw)#

Return number of unique elements in the group.

Returns

Number of unique values within each group.

Return type

Series

Examples

For SeriesGroupby:

>>> 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

For Resampler:

>>> ser = pd.Series([1, 2, 3, 3], index=pd.DatetimeIndex(  
...                 ['2023-01-01', '2023-01-15', '2023-02-01', '2023-02-15']))
>>> ser  
2023-01-01    1
2023-01-15    2
2023-02-01    3
2023-02-15    3
dtype: int64
>>> ser.resample('MS').nunique()  
2023-01-01    2
2023-02-01    1
Freq: MS, dtype: int64

This docstring was copied from pandas.core.groupby.generic.SeriesGroupBy.