Skip to main content
`Ctrl`+`K`

# pandas.api.typing.Rolling.nunique

Rolling.nunique(numeric_only=False)

  Calculate the rolling nunique.

  Added in version 3.0.0.

  Parameters:
    numeric_only bool, default False

      Include only float, int, boolean columns.

  Returns:
    Series or DataFrame

      Return type is the same as the original object with `np.float64` dtype.

  See also

  `Series.rolling`

    Calling rolling with Series data.

  `DataFrame.rolling`

    Calling rolling with DataFrames.

  `Series.nunique`

    Aggregating nunique for Series.

  `DataFrame.nunique`

    Aggregating nunique for DataFrame.

  Examples

      >>> s = pd.Series([1, 4, 2, np.nan, 3, 3, 4, 5])
      >>> s.rolling(3).nunique()
      0    NaN
      1    NaN
      2    3.0
      3    NaN
      4    NaN
      5    NaN
      6    2.0
      7    3.0
      dtype: float64