diff --git a/narwhals/_arrow/utils.py b/narwhals/_arrow/utils.py index 0012860d1..a821677f5 100644 --- a/narwhals/_arrow/utils.py +++ b/narwhals/_arrow/utils.py @@ -6,6 +6,7 @@ from typing import Generator from typing import Sequence +from narwhals.translate import to_py_scalar from narwhals.utils import isinstance_or_issubclass if TYPE_CHECKING: @@ -463,6 +464,6 @@ def _rolling( if num_valid >= min_periods: valid_weights = weights_.slice(0, num_valid) - yield aggregate_function(valid_window, valid_weights) + yield to_py_scalar(aggregate_function(valid_window, valid_weights)) else: yield None diff --git a/narwhals/_pandas_like/series.py b/narwhals/_pandas_like/series.py index 82cf2c4f6..1150ec908 100644 --- a/narwhals/_pandas_like/series.py +++ b/narwhals/_pandas_like/series.py @@ -694,7 +694,7 @@ def rolling_mean( if weights is not None: msg = ( "`weights` argument is not supported in `rolling_mean` for " - f"{self._implementation} backend." + "pandas-like backend." ) raise NotImplementedError(msg) diff --git a/tests/expr_and_series/rolling_mean_test.py b/tests/expr_and_series/rolling_mean_test.py index d99086f25..ad318e50d 100644 --- a/tests/expr_and_series/rolling_mean_test.py +++ b/tests/expr_and_series/rolling_mean_test.py @@ -63,7 +63,7 @@ def test_weighted_rolling_mean_expr(constructor: Constructor) -> None: NotImplementedError, match=re.escape("`weights` argument is not supported in `rolling_mean`"), ) - if "pandas" in str(constructor) or "dask" in str(constructor) + if any(x in str(constructor) for x in ("pandas", "modin", "cudf", "dask")) else does_not_raise() ) df = nw.from_native(constructor(data_weighted)) @@ -82,7 +82,7 @@ def test_weighted_rolling_mean_series(constructor_eager: ConstructorEager) -> No NotImplementedError, match=re.escape("`weights` argument is not supported in `rolling_mean`"), ) - if "pandas" in str(constructor_eager) + if any(x in str(constructor_eager) for x in ("pandas", "modin", "cudf")) else does_not_raise() ) df = nw.from_native(constructor_eager(data_weighted), eager_only=True)