BUG: Inconsistent correlation between constant series (varies with number of rows) #37448
Closed
2 of 3 tasks
Labels
Milestone
Uh oh!
There was an error while loading. Please reload this page.
I have checked that this issue has not already been reported (might be another variant of Correlation inconsistencies between Series and DataFrame #20954).
I have confirmed this bug exists on the latest version of pandas (
1.1.3
).(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
gives
Problem description
Inconsistent output with slightly varying number of rows. Would expect correlation between series where at least one of them is constant, to be
NaN
.This makes e.g. code dependent on
dropna()
usage after calculatingcorr()
difficult/error prone, as behaviour is inconsistent.Expected Output
Either consistent
NaN
output when calculating correlation with constant data, or a warning inpandas.DataFrame.corr
documentation stating that returned correlation between constant series can be anything from[1.0, -1.0, NaN]
.The text was updated successfully, but these errors were encountered: