Repository: dask/dask

Issue:
Deprecate axis keyword in rolling
https://pandas.pydata.org/docs/dev/reference/api/pandas.DataFrame.rolling.html

pandas deprecated the arg as well

Discussion:
github-actions[bot]: ## Unit Test Results
_See [test report](https://dask.github.io/dask/test_report.html) for an extended history of previous test failures. This is useful for diagnosing flaky tests._

     15 files  ±0       15 suites  ±0   3h 24m 57s :stopwatch: - 4m 19s
 12 940 tests ±0   11 577 :white_check_mark: +8     929 :zzz: ±0  434 :x:  - 8 
160 317 runs  ±0  142 995 :white_check_mark: +2  16 888 :zzz: +6  434 :x:  - 8 

For more details on these failures, see [this check](https://github.com/dask/dask/runs/20524171888).

Results for commit 4b63069f. ± Comparison against base commit 981c95b1.

[test-results]:data:application/gzip;base64,H4sIAH1YpmUC/1XMSw7CIBSF4a00jB1wefa6GQMUEmIfhsLIuHdptVSH5zvJ/yQhjn4l1w7kpSNriflcQ0kmx2XeNmOoK9U37z9DQY99W4tzG4LU+sR7fFREho2CiWMlwUUjn9KSqm2xVOa9rSgH/d2tLRiibPhpg+r7/rC/+C6/bbdMU8x1EGEVpwqD9D4MoA0L1FLuPDWKCvBgg1BgNSevN/0rj+AdAQAA


Patch:
diff --git a/dask/dataframe/core.py b/dask/dataframe/core.py
index 79091a18d..ca09cb9c8 100644
--- a/dask/dataframe/core.py
+++ b/dask/dataframe/core.py
@@ -2158,6 +2158,7 @@ Dask Name: {name}, {layers}"""
         else:
             return lambda self, other: elemwise(op, self, other)
 
+    @_deprecated_kwarg("axis", None)
     def rolling(
         self, window, min_periods=None, center=False, win_type=None, axis=no_default
     ):


Test patch:
diff --git a/dask/dataframe/tests/test_rolling.py b/dask/dataframe/tests/test_rolling.py
index 68338764f..541f7f5f9 100644
--- a/dask/dataframe/tests/test_rolling.py
+++ b/dask/dataframe/tests/test_rolling.py
@@ -330,8 +330,12 @@ def test_rolling_raises():
     pytest.raises(ValueError, lambda: ddf.rolling(-1))
     pytest.raises(ValueError, lambda: ddf.rolling(3, min_periods=1.2))
     pytest.raises(ValueError, lambda: ddf.rolling(3, min_periods=-2))
-    pytest.raises(ValueError, lambda: ddf.rolling(3, axis=10))
-    pytest.raises(ValueError, lambda: ddf.rolling(3, axis="coulombs"))
+
+    axis_deprecated = pytest.warns(FutureWarning, match="'axis' keyword is deprecated")
+    with axis_deprecated:
+        pytest.raises(ValueError, lambda: ddf.rolling(3, axis=10))
+    with axis_deprecated:
+        pytest.raises(ValueError, lambda: ddf.rolling(3, axis="coulombs"))
     pytest.raises(NotImplementedError, lambda: ddf.rolling(100).mean().compute())
 
 
@@ -356,23 +360,31 @@ def test_rolling_axis(kwargs):
     df = pd.DataFrame(np.random.randn(20, 16))
     ddf = dd.from_pandas(df, npartitions=3)
 
-    ctx = contextlib.nullcontext()
+    axis_deprecated_pandas = contextlib.nullcontext()
     if PANDAS_GE_210:
-        ctx = pytest.warns(FutureWarning, match="The 'axis' keyword|Support for axis")
+        axis_deprecated_pandas = pytest.warns(
+            FutureWarning, match="'axis' keyword|Support for axis"
+        )
+
+    axis_deprecated_dask = pytest.warns(
+        FutureWarning, match="'axis' keyword is deprecated"
+    )
 
     if kwargs["axis"] == "series":
         # Series
-        with ctx:
+        with axis_deprecated_pandas:
             expected = df[3].rolling(5, axis=0).std()
-        with ctx:
+        with axis_deprecated_dask:
             result = ddf[3].rolling(5, axis=0).std()
         assert_eq(expected, result)
     else:
         # DataFrame
-        with ctx:
+        with axis_deprecated_pandas:
             expected = df.rolling(3, **kwargs).mean()
         if kwargs["axis"] in (1, "rows") and not PANDAS_GE_210:
             ctx = pytest.warns(FutureWarning, match="Using axis=1 in Rolling")
+        elif "axis" in kwargs:
+            ctx = axis_deprecated_dask
         with ctx:
             result = ddf.rolling(3, **kwargs).mean()
         assert_eq(expected, result)