-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: .corr() values higher than 1 #35135
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
From a subset of your date:
One gets:
|
these are numerical precision issues |
@jreback In that case, should we have rounded the calculations / output of |
@gimseng Another potential solution other than rounding would be to use *though pandas formula for Pearson correlation is the numerically stable version. |
It also depends on both the CPU and the operating system. Using the most stable version doesn't mean that calculations are not subject to numerical precision limits. |
Closing as this is not an issue with pandas, but just numerical computations. |
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
Sorry for including an external dataset. I couldn't reproduce this bug with a smaller one.
Problem description
When applying .corr() on the given dataset the output Pearson's correlation is slightly >1 (6.661338e-16). I'd assume it should be equal to 1.
Expected Output
The expected result would be correlation values <= 1.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.7.7.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 9, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 1.0.5
numpy : 1.18.5
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 47.3.0.post20200616
Cython : None
pytest : None
hypothesis : None
sphinx : 3.1.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.15.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.2.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : 0.49.1
The text was updated successfully, but these errors were encountered: