Skip to main content
`Ctrl`+`K`

# pandas.api.typing.Resampler.nunique

final Resampler.nunique()

  Return number of unique elements in the group.

  This method counts the number of distinct values within each resampled time period.

  Returns:
    Series

      Number of unique values within each group.

  See also

  `core.groupby.SeriesGroupBy.nunique`

    Method nunique for SeriesGroupBy.

  Examples

      >>> ser = pd.Series(
      ...     [1, 2, 3, 3],
      ...     index=pd.DatetimeIndex(
      ...         ["2023-01-01", "2023-01-15", "2023-02-01", "2023-02-15"]
      ...     ),
      ... )
      >>> ser
      2023-01-01    1
      2023-01-15    2
      2023-02-01    3
      2023-02-15    3
      dtype: int64
      >>> ser.resample("MS").nunique()
      2023-01-01    2
      2023-02-01    1
      Freq: MS, dtype: int64