Skip to content

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

Closed
@goodwanghan

Description

@goodwanghan
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugWindowrolling, ewma, expanding

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions