Skip to content

Commit d1b6f9b

Browse files
committed
roll_var: move prev_value out from cdef
1 parent 6ece6a6 commit d1b6f9b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pandas/_libs/window/aggregations.pyx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ 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 = values[start[0]]
365+
float64_t compensation_remove, prev_value
366366
int64_t s, e, num_consecutive_same_value = 0
367367
Py_ssize_t i, j, N = len(start)
368368
ndarray[float64_t] output
@@ -385,6 +385,8 @@ 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+
388390
mean_x = ssqdm_x = nobs = compensation_add = compensation_remove = 0
389391
for j in range(s, e):
390392
add_var(values[j], &nobs, &mean_x, &ssqdm_x, &compensation_add,

0 commit comments

Comments
 (0)