Skip to content

Commit 7c93140

Browse files
committed
restricted clipping to when cov=False
1 parent f0573e1 commit 7c93140

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pandas/_libs/algos.pyx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,11 @@ def nancorr(const float64_t[:, :] mat, bint cov=False, minp=None):
391391
# clip `covxy / divisor` to ensure coeff is within bounds
392392
if divisor != 0:
393393
val = covxy / divisor
394-
if val > 1.0:
395-
val = 1.0
396-
elif val < -1.0:
397-
val = -1.0
394+
if not cov:
395+
if val > 1.0:
396+
val = 1.0
397+
elif val < -1.0:
398+
val = -1.0
398399
result[xi, yi] = result[yi, xi] = val
399400
else:
400401
result[xi, yi] = result[yi, xi] = NaN

0 commit comments

Comments
 (0)