dask.dataframe.tseries.resample.Resampler.nunique

Resampler.nunique()[source]

Return number of unique elements in the group.

This docstring was copied from pandas.core.resample.Resampler.nunique.

Some inconsistencies with the Dask version may exist.

Returns:
Series

Number of unique values within each group.

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