From bfe9ad2b27d3479e555316f4a9cf276a29679031 Mon Sep 17 00:00:00 2001 From: Matt Roeschke Date: Mon, 22 Jun 2020 00:29:07 -0700 Subject: [PATCH 1/2] CLN: Update Cython data pointers for rolling apply --- pandas/_libs/window/aggregations.pyx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pandas/_libs/window/aggregations.pyx b/pandas/_libs/window/aggregations.pyx index 646444d10e416..ab4d96cbbdc2f 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): From 2ebfcc4eca6b396d8da6a5ec9a0a34122b9d565f Mon Sep 17 00:00:00 2001 From: Matt Roeschke Date: Mon, 22 Jun 2020 00:35:05 -0700 Subject: [PATCH 2/2] Spacing --- pandas/_libs/window/aggregations.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/window/aggregations.pyx b/pandas/_libs/window/aggregations.pyx index ab4d96cbbdc2f..ec4a412b5adc7 100644 --- a/pandas/_libs/window/aggregations.pyx +++ b/pandas/_libs/window/aggregations.pyx @@ -1379,7 +1379,7 @@ def roll_generic_fixed(object obj, # remaining full-length windows for j, i in enumerate(range((win - offset), (N - offset)), 1): if counts[i] >= minp: - output[i] = func(arr[j : j + win], *args, **kwargs) + output[i] = func(arr[j:j + win], *args, **kwargs) else: output[i] = NaN