You are viewing documentation about an older version (1.21.0). View latest version

modin.pandas.Series.nunique¶

Series.nunique(dropna=True)[source]¶

Return number of unique elements in the series.

Excludes NA values by default. Snowpark pandas API does not distinguish between different NaN types like None, pd.NA, and np.nan, and treats them as the same.

Parameters:

dropna (bool, default True) – Don’t include NaN in the count.

Return type:

int

Examples

>>> import snowflake.snowpark.modin.pandas as pd
>>> import numpy as np
>>> s = pd.Series([1, 3, 5, 7, 7])
>>> s
0    1
1    3
2    5
3    7
4    7
dtype: int64
Copy
>>> s.nunique()
4
Copy
>>> s = pd.Series([pd.NaT, np.nan, pd.NA, None, 1])
>>> s.nunique()
1
Copy
>>> s.nunique(dropna=False)
2
Copy