diff --git a/pandas/_libs/window/aggregations.pyi b/pandas/_libs/window/aggregations.pyi index f3317ff5a60be..b926a7cb73425 100644 --- a/pandas/_libs/window/aggregations.pyi +++ b/pandas/_libs/window/aggregations.pyi @@ -6,7 +6,10 @@ from typing import ( import numpy as np -from pandas._typing import WindowingRankType +from pandas._typing import ( + WindowingRankType, + npt, +) def roll_sum( values: np.ndarray, # const float64_t[:] @@ -83,7 +86,7 @@ def roll_apply( raw: bool, args: tuple[Any, ...], kwargs: dict[str, Any], -) -> np.ndarray: ... # np.ndarray[float] # FIXME: could also be type(obj) if n==0 +) -> npt.NDArray[np.float64]: ... def roll_weighted_sum( values: np.ndarray, # const float64_t[:] weights: np.ndarray, # const float64_t[:] diff --git a/pandas/_libs/window/aggregations.pyx b/pandas/_libs/window/aggregations.pyx index 98201a6f58499..be8bb61092362 100644 --- a/pandas/_libs/window/aggregations.pyx +++ b/pandas/_libs/window/aggregations.pyx @@ -1271,7 +1271,7 @@ def roll_apply(object obj, Py_ssize_t i, s, e, N = len(start), n = len(obj) if n == 0: - return obj + return np.array([], dtype=np.float64) arr = np.asarray(obj)