Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: min_period not effecting rolling #56287

Closed
3 tasks done
jamespreed opened this issue Dec 1, 2023 · 1 comment
Closed
3 tasks done

BUG: min_period not effecting rolling #56287

jamespreed opened this issue Dec 1, 2023 · 1 comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@jamespreed
Copy link

Pandas version checks

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

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

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

x = pd.DataFrame({'x': range(20)})

for r in x.rolling(window=15, min_periods=15):
    print(r.shape)

# output:
(1, 1)
(2, 1)
(3, 1)
(4, 1)
(5, 1)
(6, 1)
(7, 1)
(8, 1)
(9, 1)
(10, 1)
(11, 1)
(12, 1)
(13, 1)
(14, 1)
(15, 1)
(15, 1)
(15, 1)
(15, 1)
(15, 1)
(15, 1)

Issue Description

I may be misunderstanding the documentation, but when using min_periods with an integer window value, I would expect that all of the windows would be at least as big as min_periods. Instead it starts with a windows of size 1 and goes up to window.

Expected Behavior

I expected that when window=15 and min_periods=15, that all windows would be of length 15.

(15, 1)
(15, 1)
(15, 1)
(15, 1)
(15, 1)
(15, 1)

Installed Versions

INSTALLED VERSIONS

commit : e86ed37
python : 3.10.13.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.22621
machine : AMD64
processor : Intel64 Family 6 Model 151 Stepping 5, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252

pandas : 2.1.1
numpy : 1.26.2
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 68.0.0
pip : 23.3.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 8.15.0
pandas_datareader : None
bs4 : None
bottleneck : 1.3.5
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.8.0
numba : None
numexpr : 2.8.7
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.11.4
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

@jamespreed jamespreed added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 1, 2023
@mroeschke
Copy link
Member

Thanks but this is the expected behavior

Minimum number of observations in window required to have a value; otherwise, result is np.nan.

See the example in https://pandas.pydata.org/docs/user_guide/window.html#windowing-operations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

2 participants