-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: pandas.core.window.rolling.Rolling.std gives all-zero output for small numbers #39872
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
Comments
Thanks for the report. This is a known limitation in the rolling aggregations and we're currently discussing on how to to best communicate it in #37051, so going to close in favor of that issue |
Hey, sorry if I am wrong, but as far as I understand #37051 you are only rounding if differences in the method of calculating the |
Fixes #62 * Added python2 input parameter * bugfix with duplicated column names * limit pandas version <1.2 because of pandas-dev/pandas#39872 * updated changelog
The code mentioned #37051 is a limit set for variances ops (which |
Ah, I missed the variance part. Thank you very much for the explanation! |
I disagree with closing this, we are encountering the same problem while calculating mean (and std) on top of Crypto asset prices (which can become numbers down to 1e-8). while #37051 does discuss this - it's not mentioned as a side-effect as part of the release docs for pandas 1.2 - so i would see this as an unintended regression. A very simple example: import pandas as pd
print(pd.__version__)
df = pd.DataFrame(data = {'data':
[
0.00000054,
0.00000053,
0.00000054,
]}
)
df['mean'] = df['data'].rolling(2).mean()
df['std'] = df['data'].rolling(2).std()
print(df) with pandas < 1.2.0, the return is as follows:
while 1.2.0 returns:
The values are nowhere near the mentioned threshold of 1e-15. |
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.
Code Sample, a copy-pastable example
Problem description
It seems
std()
on a rolling window in pandas 1.2.2 rounds the numbers to exact0.0
if the result would be< 1.0e-7
.In comparison, version 1.1.2 gave the correct result.
Expected Output
Output in Pandas 1.1.2
INSTALLED VERSIONS
commit : 2a7d332
python : 3.7.8.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.72-microsoft-standard-WSL2
Version : #1 SMP Wed Oct 28 23:40:43 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.1.2
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.3
setuptools : 47.1.0
Cython : None
pytest : 5.4.3
hypothesis : 5.20.3
sphinx : 3.1.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.6.1
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.16.1
pandas_datareader: None
bs4 : 4.9.3
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.0
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.5.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
Actual Output
Output in Pandas 1.2.2
INSTALLED VERSIONS
commit : 7d32926
python : 3.7.8.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.72-microsoft-standard-WSL2
Version : #1 SMP Wed Oct 28 23:40:43 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.2.2
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.3
setuptools : 47.1.0
Cython : None
pytest : 5.4.3
hypothesis : 5.20.3
sphinx : 3.1.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.6.1
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.16.1
pandas_datareader: None
bs4 : 4.9.3
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.0
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.5.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: