BUG: Rolling skew error (original) (raw)

Pandas version checks

Reproducible Example

import pandas as pd data =[-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,7729964027,7729965641,7729965103,7729966179,7729968330,7729969406,7729971020,7729969406,7729969944,7729969406,7729969406,7729969944,7729971558,7729972633,7729973171,7729973171,7729973171,7729969406]

df=pd.DataFrame(data,columns = ['data']) df.data.rolling(10).skew() 43 -1.778781e+00 44 -3.162278e+00 45 -1.311680e+03 46 2.681674e+04 47 5.244346e+03 48 5.565501e+03 49 4.143785e+04 50 1.921654e+04 51 -7.723187e+03 52 1.171920e+04 53 1.171920e+04

df.data.tail(10).skew() 0.16889762763904356

#Same problem for kurt()! df.data.rolling(10).kurt()[-1:] 53 -4.518855e+10

df.data.tail(10).kurt() -2.198110595961745

Issue Description

When there is a large spread in the exponent of values in the data, then rolling().skew() and tail().skew() come to different results.

Expected Behavior

The results must be equal.

Installed Versions

Details

INSTALLED VERSIONS

commit : 06d2301
python : 3.9.7.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19044
machine : AMD64
processor : AMD64 Family 23 Model 1 Stepping 1, AuthenticAMD
byteorder : little
LC_ALL : None
LANG : None
LOCALE : Russian_Russia.1251

pandas : 1.4.1
numpy : 1.22.2
pytz : 2021.3
dateutil : 2.8.2
pip : 22.0.4
setuptools : 62.4.0
Cython : 0.29.27
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.7.1
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.3
IPython : 8.0.1
pandas_datareader: None
bs4 : 4.10.0
bottleneck : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.5.1
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.7.3
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None