dask.dataframe.groupby.SeriesGroupBy.nunique

SeriesGroupBy.nunique(split_every=None, split_out=1)[source]

Return number of unique elements in the group.

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

Some inconsistencies with the Dask version may exist.

Returns
Series

Number of unique values within each group.

Examples

>>> import pandas as pd  
>>> import dask.dataframe as dd  
>>> d = {'col1': [1, 2, 3, 4], 'col2': [5, 6, 7, 8]}  
>>> df = pd.DataFrame(data=d)  
>>> ddf = dd.from_pandas(df, 2)  
>>> ddf.groupby(['col1']).col2.nunique().compute()