pandas.Series.nunique¶
Return number of unique elements in the object.
Excludes NA values by default.
- param dropna
- bool, default True
Don’t include NaN in the count.
- return
int
Limitations¶
- This function may reveal slower performance than Pandas* on user system. Users should exercise a tradeoff
between staying in JIT-region with that function or going back to interpreter mode.
Examples¶
import pandas as pd
from numba import njit
@njit
def series_nunique():
series = pd.Series([2, 8, 2, 1])
return series.nunique() # Expect value: 3
print(series_nunique())
$ python ./series/series_nunique.py
3
See also
- DataFrame.nunique
Method nunique for DataFrame.
- Series.count
Count non-NA/null observations in the Series.
- DatatFrame.count
Count non-NA cells for each column