Skip to content

Commit 1924be3

Browse files
authored
PERF: use c-division in nancorr (#47518)
1 parent 1ac1391 commit 1924be3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pandas/_libs/algos.pyx

+3-2
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ def kth_smallest(numeric_t[::1] arr, Py_ssize_t k) -> numeric_t:
324324

325325
@cython.boundscheck(False)
326326
@cython.wraparound(False)
327+
@cython.cdivision(True)
327328
def nancorr(const float64_t[:, :] mat, bint cov=False, minp=None):
328329
cdef:
329330
Py_ssize_t i, j, xi, yi, N, K
@@ -356,8 +357,8 @@ def nancorr(const float64_t[:, :] mat, bint cov=False, minp=None):
356357
nobs += 1
357358
dx = vx - meanx
358359
dy = vy - meany
359-
meanx += 1 / nobs * dx
360-
meany += 1 / nobs * dy
360+
meanx += 1. / nobs * dx
361+
meany += 1. / nobs * dy
361362
ssqdmx += (vx - meanx) * dx
362363
ssqdmy += (vy - meany) * dy
363364
covxy += (vx - meanx) * dy

0 commit comments

Comments
 (0)