Skip to content

Commit d63760a

Browse files
committed
clip correlation coefficient between -1 and 1
1 parent c0371ce commit d63760a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pandas/core/frame.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11233,6 +11233,9 @@ def corr(
1123311233
f"'{method}' was supplied"
1123411234
)
1123511235

11236+
# clip coefficient to ensure it is within theoretical bounds
11237+
correl = np.clip(correl, -1, 1)
11238+
1123611239
result = self._constructor(correl, index=idx, columns=cols, copy=False)
1123711240
return result.__finalize__(self, method="corr")
1123811241

0 commit comments

Comments
 (0)