Skip to content

Commit 7eddd90

Browse files
committed
TEMP: add path for using nanops_numba in masked array reductions
1 parent d3d3c11 commit 7eddd90

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pandas/core/array_algos/masked_reductions.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77

88
from typing import TYPE_CHECKING
99
import warnings
10+
from inspect import signature
1011

1112
import numpy as np
1213

1314
from pandas._libs import missing as libmissing
1415

15-
from pandas.core.nanops import check_below_min_count
16+
from pandas.core.nanops import check_below_min_count, _USE_NUMBA, nanops_numba
1617

1718
if TYPE_CHECKING:
1819
from collections.abc import Callable
@@ -51,6 +52,14 @@ def _reductions(
5152
``min_count`` non-NA values are present the result will be NA.
5253
axis : int, optional, default None
5354
"""
55+
if _USE_NUMBA:
56+
nanop = getattr(nanops_numba, f"nan{func.__name__}", None)
57+
if nanop is not None:
58+
kwargs = dict(mask=mask, skipna=skipna, axis=axis)
59+
if "min_count" in signature(nanop).parameters:
60+
kwargs["min_count"] = min_count
61+
return nanop(values, **kwargs)
62+
5463
if not skipna:
5564
if mask.any() or check_below_min_count(values.shape, None, min_count):
5665
return libmissing.NA

0 commit comments

Comments
 (0)