- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 19.2k
Description
Pandas version checks
- 
I have checked that this issue has not already been reported. 
- 
I have confirmed this bug exists on the latest version of pandas. 
- 
I have confirmed this bug exists on the main branch of pandas. 
Reproducible Example
values = [{'col1': 30.0, 'col2': 116.80000305175781},
 {'col1': None, 'col2': None},
 {'col1': None, 'col2': None},
 {'col1': None, 'col2': None},
 {'col1': None, 'col2': None},
 {'col1': None, 'col2': None},
 {'col1': None, 'col2': None},
 {'col1': None, 'col2': None},
 {'col1': None, 'col2': None},
 {'col1': None, 'col2': None},
 {'col1': None, 'col2': None},
 {'col1': None, 'col2': None},
 {'col1': None, 'col2': None},
 {'col1': 30.100000381469727, 'col2': 116.8000030517578},
 {'col1': None, 'col2': None},
 {'col1': None, 'col2': None}]
data = pd.DataFrame(values)
data.corr(method='pearson')Issue Description
In the code snipped I'm trying to calculate the correlation between a pair of columns. However, when using pearson correlation method for this particular example, the outputted correlation is outside the -1 to 1 expected range.
Expected Behavior
The output of the pearson correlation method should be inside the -1 to 1 range.
Installed Versions
INSTALLED VERSIONS
commit                : d9cdd2e
python                : 3.9.19.final.0
python-bits           : 64
OS                    : Linux
OS-release            : 5.10.223-211.872.amzn2.x86_64
Version               : #1 SMP Mon Jul 29 19:52:29 UTC 2024
machine               : x86_64
processor             : x86_64
byteorder             : little
LC_ALL                : C.UTF-8
LANG                  : C.UTF-8
LOCALE                : en_US.UTF-8
pandas                : 2.2.2
numpy                 : 1.26.4
pytz                  : 2024.1
dateutil              : 2.9.0.post0
setuptools            : 69.5.1
pip                   : 24.0
Cython                : None
pytest                : None
hypothesis            : None
sphinx                : None
blosc                 : None
feather               : None
xlsxwriter            : None
lxml.etree            : None
html5lib              : None
pymysql               : None
psycopg2              : None
jinja2                : 3.1.4
IPython               : 8.18.1
pandas_datareader     : None
adbc-driver-postgresql: None
adbc-driver-sqlite    : None
bs4                   : None
bottleneck            : None
dataframe-api-compat  : None
fastparquet           : None
fsspec                : None
gcsfs                 : None
matplotlib            : 3.9.2
numba                 : None
numexpr               : None
odfpy                 : None
openpyxl              : 3.1.5
pandas_gbq            : None
pyarrow               : 14.0.1
pyreadstat            : None
python-calamine       : None
pyxlsb                : None
s3fs                  : None
scipy                 : 1.10.1
sqlalchemy            : 2.0.31
tables                : None
tabulate              : None
xarray                : None
xlrd                  : None
zstandard             : None
tzdata                : 2024.1
qtpy                  : None
pyqt5                 : None