Skip to content

BUG: rolling count on FixedForwardWindowIndexer returns NaN instead of 0 #35579

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
2 of 3 tasks
goodwanghan opened this issue Aug 5, 2020 · 5 comments · Fixed by #36649
Closed
2 of 3 tasks

BUG: rolling count on FixedForwardWindowIndexer returns NaN instead of 0 #35579

goodwanghan opened this issue Aug 5, 2020 · 5 comments · Fixed by #36649
Labels
Bug Window rolling, ewma, expanding
Milestone

Comments

@goodwanghan
Copy link

  • 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.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

import pandas as pd
from pandas.core.window.indexers import FixedForwardWindowIndexer

df = pd.DataFrame([[0, None], [0, None],[0, None],[0, 7]], columns=["a", "b"])
res = df["b"].rolling(window=FixedForwardWindowIndexer(window_size=2),min_periods=0).count()
print(res)

Problem description

Current output:
0 NaN
1 NaN
2 1.0
3 1.0

Expected Output

0 0.0
1 0.0
2 1.0
3 1.0

Output of pd.show_versions()

INSTALLED VERSIONS

commit : d9fff27
python : 3.6.9.final.0
python-bits : 64
OS : Linux
OS-release : 5.6.13-100.fc30.x86_64
Version : #1 SMP Fri May 15 00:36:06 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : C.UTF-8
LANG : C.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.1.0
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 9.0.3
setuptools : 45.2.0
Cython : None
pytest : 4.6.4
hypothesis : None
sphinx : 3.1.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.5.2
html5lib : None
pymysql : None
psycopg2 : 2.8.5 (dt dec pq3 ext lo64)
jinja2 : 2.10.1
IPython : 7.15.0
pandas_datareader: None
bs4 : 4.9.1
bottleneck : None
fsspec : 0.7.4
fastparquet : 0.4.1
gcsfs : 0.6.2
matplotlib : 3.3.0
numexpr : 2.7.1
odfpy : None
openpyxl : None
pandas_gbq : 0.10.0
pyarrow : 1.0.0
pytables : None
pyxlsb : None
s3fs : 0.2.2
scipy : 1.3.1
sqlalchemy : 1.3.18
tables : 3.6.1
tabulate : 0.8.7
xarray : None
xlrd : None
xlwt : None
numba : 0.50.1

@goodwanghan goodwanghan added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 5, 2020
@goodwanghan
Copy link
Author

I also tested with custom BaseIndexer, it seems as long as there is forward looking, it has this issue

@mroeschke
Copy link
Member

cc @AlexKirko

@simonjayhawkins
Copy link
Member

since FixedForwardWindowIndexer was added in 1.1.0, just in case a fix is needed, i'll add the 1.1.1 milestone for now pending further investigation/discussion

@simonjayhawkins simonjayhawkins added this to the 1.1.1 milestone Aug 7, 2020
@goodwanghan
Copy link
Author

FixedForwardWindowIndexer has this issue because it is forward looking, I also tried custom BaseIndexer with forward looking, it has the same issue. So the problem may not be on FixedForwardWindowIndexer but on the deeper layers

@simonjayhawkins simonjayhawkins modified the milestones: 1.1.1, 1.1.2 Aug 20, 2020
@jbrockmendel jbrockmendel added Window rolling, ewma, expanding and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 3, 2020
@simonjayhawkins simonjayhawkins modified the milestones: 1.1.2, 1.1.3 Sep 7, 2020
@simonjayhawkins
Copy link
Member

moved off 1.1.2 milestone (scheduled for this week) as no PRs to fix in the pipeline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Window rolling, ewma, expanding
Projects
None yet
4 participants