Skip to content

Commit 6ece6a6

Browse files
committed
roll_var move to cdef
1 parent 7909ffe commit 6ece6a6

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

pandas/_libs/window/aggregations.pyx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ def roll_var(const float64_t[:] values, ndarray[int64_t] start,
362362
"""
363363
cdef:
364364
float64_t mean_x, ssqdm_x, nobs, compensation_add,
365-
float64_t compensation_remove, prev_value
366-
int64_t s, e, num_consecutive_same_value
365+
float64_t compensation_remove, prev_value = values[start[0]]
366+
int64_t s, e, num_consecutive_same_value = 0
367367
Py_ssize_t i, j, N = len(start)
368368
ndarray[float64_t] output
369369
bint is_monotonic_increasing_bounds
@@ -385,9 +385,6 @@ def roll_var(const float64_t[:] values, ndarray[int64_t] start,
385385
# never removed
386386
if i == 0 or not is_monotonic_increasing_bounds or s >= end[i - 1]:
387387

388-
prev_value = values[s]
389-
num_consecutive_same_value = 0
390-
391388
mean_x = ssqdm_x = nobs = compensation_add = compensation_remove = 0
392389
for j in range(s, e):
393390
add_var(values[j], &nobs, &mean_x, &ssqdm_x, &compensation_add,

0 commit comments

Comments
 (0)