diff --git a/pandas/_libs/window/aggregations.pyx b/pandas/_libs/window/aggregations.pyx index 646444d10e416..ec4a412b5adc7 100644 --- a/pandas/_libs/window/aggregations.pyx +++ b/pandas/_libs/window/aggregations.pyx @@ -1377,17 +1377,11 @@ def roll_generic_fixed(object obj, output[i] = NaN # remaining full-length windows - buf = arr.data - bufarr = np.empty(win, dtype=float) - oldbuf = bufarr.data - for i in range((win - offset), (N - offset)): - buf = buf + 1 - bufarr.data = buf + for j, i in enumerate(range((win - offset), (N - offset)), 1): if counts[i] >= minp: - output[i] = func(bufarr, *args, **kwargs) + output[i] = func(arr[j:j + win], *args, **kwargs) else: output[i] = NaN - bufarr.data = oldbuf # truncated windows at the end for i in range(int_max(N - offset, 0), N):