Skip to content

Commit 7f2fdaa

Browse files
committed
Transfered np.clip to algos.nancorr
1 parent a997140 commit 7f2fdaa

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pandas/_libs/algos.pyx

+3
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,9 @@ def nancorr(const float64_t[:, :] mat, bint cov=False, minp=None):
394394
else:
395395
result[xi, yi] = result[yi, xi] = NaN
396396

397+
# clip coefficient to ensure it is within theoretical bounds
398+
result = np.clip(result, -1, 1)
399+
397400
return result.base
398401

399402
# ----------------------------------------------------------------------

pandas/core/frame.py

-3
Original file line numberDiff line numberDiff line change
@@ -11233,9 +11233,6 @@ 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-
1123911236
result = self._constructor(correl, index=idx, columns=cols, copy=False)
1124011237
return result.__finalize__(self, method="corr")
1124111238

0 commit comments

Comments
 (0)