Skip to content

BUG: Weighted rolling aggregations do not respect min_periods=0 #51449

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

Closed
3 tasks done
Savlik opened this issue Feb 17, 2023 · 1 comment · Fixed by #51611
Closed
3 tasks done

BUG: Weighted rolling aggregations do not respect min_periods=0 #51449

Savlik opened this issue Feb 17, 2023 · 1 comment · Fixed by #51611
Assignees
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member Window rolling, ewma, expanding

Comments

@Savlik
Copy link
Contributor

Savlik commented Feb 17, 2023

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
import numpy as np

df = pd.DataFrame([np.nan, 0, 1, 2,])

print(df.rolling(window=3, win_type="exponential", min_periods=0).sum(tau=1))
#           0
# 0       NaN
# 1       NaN
# 2       NaN
# 3  1.735759
print(df.rolling(window=3, min_periods=0).sum())
#      0
# 0  0.0
# 1  0.0
# 2  1.0
# 3  3.0
print(df.rolling(window=3, win_type="exponential", min_periods=0).mean(tau=1))
#      0
# 0  NaN
# 1  NaN
# 2  NaN
# 3  1.0
print(df.rolling(window=3, min_periods=0).mean())
#      0
# 0  NaN
# 1  0.0
# 2  0.5
# 3  1.0

Issue Description

When using weighted rolling aggregation and setting min_periods to 0 does not work and it is treated as None. Aggregations without weight work as expected.

Expected Behavior

Weighted and not-weighted rolling aggregations should behave the same way with min_periods=0 and fill NaN in the same positions.

Installed Versions

commit : 2e218d1
python : 3.11.1.final.0
python-bits : 64
OS : Linux
OS-release : 5.10.102.1-microsoft-standard-WSL2
Version : #1 SMP Wed Mar 2 00:30:59 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.5.3
numpy : 1.24.1
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 66.1.1
pip : 22.2.2
Cython : None
pytest : 7.2.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.8.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.6.3
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 10.0.1
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.10.0
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : None

@Savlik Savlik added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 17, 2023
@Savlik
Copy link
Contributor Author

Savlik commented Feb 24, 2023

take

@simonjayhawkins simonjayhawkins added the Window rolling, ewma, expanding label Feb 24, 2023
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 Window rolling, ewma, expanding
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants