Skip to content

BUG: ewm*() functions interpret min_periods off by one? #7884

Closed
@seth-p

Description

@seth-p

In the examples below with min_periods=2, expanding_mean/std start to give values once there are two values, but ewma/std only once there are three values. Is this intentional? It looks like a bug to me.

In [1]: from pandas import Series, expanding_mean, expanding_std, ewma, ewmstd, show_versions

In [2]: s = Series(range(4))

In [3]: expanding_mean(s, min_periods=2)
Out[3]:
0    NaN
1    0.5
2    1.0
3    1.5
dtype: float64

In [4]: expanding_std(s, min_periods=2)
Out[4]:
0         NaN
1    0.707107
2    1.000000
3    1.290994
dtype: float64

In [5]: ewma(s, min_periods=2, halflife=3.)
Out[5]:
0         NaN
1         NaN
2    1.152678
3    1.784530
dtype: float64

In [6]: ewmstd(s, min_periods=2, halflife=3.)
Out[6]:
0         NaN
1         NaN
2    0.856493
3    1.162100
dtype: float64

In [7]: show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.4.1.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.14.1
nose: 1.3.3
Cython: 0.20.2
numpy: 1.9.0b1
scipy: 0.14.0
statsmodels: 0.5.0
IPython: 2.1.0
sphinx: 1.2.2
patsy: 0.3.0
scikits.timeseries: None
dateutil: 2.2
pytz: 2014.4
bottleneck: 0.8.0
tables: 3.1.1
numexpr: 2.4
matplotlib: 1.3.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
rpy2: None
sqlalchemy: 0.9.7
pymysql: None
psycopg2: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions