snowflake.snowpark.modin.plugin.extensions.resample_overrides.Resampler.nunique¶

Resampler.nunique(*args: Any, **kwargs: Any) → Series[source]¶

Return number of unique elements in the group.

Returns:

Number of unique values within each group.

Return type:

Series

Examples

For Series:

>>> lst1 = pd.date_range('2020-01-01', periods=4, freq='1D')
>>> ser1 = pd.Series([1, 1, 2, 2], index=lst1)
>>> ser1
2020-01-01    1
2020-01-02    1
2020-01-03    2
2020-01-04    2
Freq: None, dtype: int64
Copy
>>> ser1.resample('2D').nunique()
2020-01-01    1
2020-01-03    1
Freq: None, dtype: int64
Copy

For DataFrame:

>>> data = [[1, 8, 2], [1, 2, 5], [2, 5, 8], [2, 6, 9]]
>>> df = pd.DataFrame(data,
...      columns=["a", "b", "c"],
...      index=pd.date_range('2020-01-01', periods=4, freq='1D'))
>>> df
            a  b  c
2020-01-01  1  8  2
2020-01-02  1  2  5
2020-01-03  2  5  8
2020-01-04  2  6  9
Copy
>>> df.resample('2D').nunique()
            a  b  c
2020-01-01  1  2  2
2020-01-03  1  2  2
Copy