Skip to content

Commit 0f982d0

Browse files
authored
Merge pull request #32 from twosigma/feature/parallel_rolling_apply
Use parallel=True in rolling.apply
2 parents d34b96c + 65a5e72 commit 0f982d0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pandas/core/window/rolling.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import numpy as np
1313

1414
import pandas._libs.window as libwindow
15+
import pandas.compat as compat
1516
from pandas.compat._optional import import_optional_dependency
1617
from pandas.compat.numpy import function as nv
1718
from pandas.util._decorators import Appender, Substitution, cache_readonly
@@ -1159,15 +1160,17 @@ def impl(window, *_args):
11591160

11601161
return impl
11611162

1162-
@numba.njit
1163+
@numba.njit(nogil=True, parallel=not compat.is_platform_32bit())
11631164
def roll_apply(
11641165
values: np.ndarray,
11651166
begin: np.ndarray,
11661167
end: np.ndarray,
11671168
minimum_periods: int,
11681169
):
11691170
result = np.empty(len(begin))
1170-
for i, (start, stop) in enumerate(zip(begin, end)):
1171+
for i in numba.prange(len(result)):
1172+
start = begin[i]
1173+
stop = end[i]
11711174
window = values[start:stop]
11721175
count_nan = np.sum(np.isnan(window))
11731176
if len(window) - count_nan >= minimum_periods:

0 commit comments

Comments
 (0)