pandas.core.window.expanding.Expanding.nunique#
- Expanding.nunique(numeric_only=False)[source]#
Calculate the expanding nunique.
Added in version 3.0.0.
- Parameters:
- numeric_onlybool, default False
Include only float, int, boolean columns.
Added in version 1.5.0.
- Returns:
- Series or DataFrame
Return type is the same as the original object with
np.float64
dtype.
See also
Series.expanding
Calling expanding with Series data.
DataFrame.expanding
Calling expanding with DataFrames.
Series.nunique
Aggregating nunique for Series.
DataFrame.nunique
Aggregating nunique for DataFrame.
Examples
>>> s = pd.Series([1, 4, 2, 3, 5, 3]) >>> s.expanding().nunique() 0 1.0 1 2.0 2 3.0 3 4.0 4 5.0 5 5.0 dtype: float64