8000 BUG: rolling count does not respect the default behavior of min_periods · Issue #35972 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content 10000
BUG: rolling count does not respect the default behavior of min_periods #35972
@mroeschke

Description

@mroeschke
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.

Per the documentation:

For a window that is specified by an offset, min_periods will default to 1. Otherwise, min_periods will default to the size of the window.

Therefore these two statements should be equal

In [4]: pd.__version__
Out[4]: '1.2.0.dev0+160.gd90b73bde'

In [5]: pd.Series([np.nan] * 4).rolling(2).count()
Out[5]:
0    0.0
1    0.0
2    0.0
3    0.0
dtype: float64

In [6]: pd.Series([np.nan] * 4).rolling(2, min_periods=2).count()
Out[6]:
0    NaN
1    0.0
2    0.0
3    0.0
dtype: float64

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugWindowrolling, ewma, expanding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0