Skip to content

BUG: rolling_max with center=True and min_periods=1 returns incorrect results #6795

Closed
@apuapaquola

Description

@apuapaquola

rolling_max with center=True and min_periods=1 returns NaN's

Python 3.3.5 (default, Mar 10 2014, 03:21:31) 
[GCC 4.8.2 20140206 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> df=pd.DataFrame([0,1,2,1,0], columns=['a']

### This is OK
>>> pd.rolling_max(df['a'], window=3, center=True)
0   NaN
1     2
2     2
3     2
4   NaN
dtype: float64


### This should return [1, 2, 2, 2, 1]
>>> pd.rolling_max(df['a'], window=3, center=True, min_periods=1)
0     1
1     2
2     2
3     2
4   NaN
dtype: float64

>>> pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.3.5.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.6-1-ARCH
machine: x86_64
processor: 
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.13.1
Cython: 0.20.1
numpy: 1.8.1
scipy: 0.13.3
statsmodels: 0.5.0
IPython: 1.2.1
sphinx: 1.2.2
patsy: None
scikits.timeseries: None
dateutil: 2.2
pytz: 2014.1
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.3.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
sqlalchemy: None
lxml: None
bs4: None
html5lib: None
bq: None
apiclient: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs TestsUnit test(s) needed to prevent regressionsWindowrolling, ewma, expandinggood first issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions