modin.pandas.DataFrame.nunique¶
- DataFrame.nunique(axis=0, dropna=True) Series | int [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/.tox/docs/lib/python3.9/site-packages/modin/pandas/base.py#L2270-L2277)¶
Count number of distinct elements in specified axis.
Return Series with number of distinct elements. Can ignore NaN values. Snowpark pandas API does not distinguish between different NaN types like None, pd.NA, and np.nan, and treats them as the same.
- Parameters:
axis ({0 or 'index', 1 or 'columns'}, default 0) – The axis to use. 0 or ‘index’ for row-wise, 1 or ‘columns’ for column-wise. Snowpark pandas currently only supports axis=0.
dropna (bool, default True) – Don’t include NaN in the counts.
- Return type:
Examples
>>> df = pd.DataFrame({'A': [4, 5, 6], 'B': [4, 1, 1]}) >>> df.nunique() A 3 B 2 dtype: int64
>>> df = pd.DataFrame({'A': [None, pd.NA, None], 'B': [1, 2, 1]}) >>> df.nunique() A 0 B 2 dtype: int64
>>> df.nunique(dropna=False) A 1 B 2 dtype: int64