ENH: Rolling window with step size (GH-15354)
- [x] closes #15354
- [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [x] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.

@mroeschke, @jreback: This PR replaces [#45735](https://github.com/pandas-dev/pandas/pull/45735). The current changeset I prepared passes the original unchanged window tests, indicating that the new behavior does not break existing behaviors. After this changeset is worked out in review, the next changeset will add new tests. @rtpsw can you merge master and i think a few open comments. I reverted to the original signature of `get_window_bounds`, so now group-by, emw and expand do not support a `step` argument with non-default behavior. I minimally modified the existing tests to allow them to pass - basically just adjusting the signature of `get_window_bounds` in custom indexers derived from `BaseIndexer`. If the code looks reasonable to you, I'll proceed to add back to this PR (using code from the cancelled PR) the test cases that cover the new `step` parameter functionality. I added the tests. Please review. AFAICS, the current test failures are not related to my changes and possibly got introduced by a merge from master. How to handle them? @mroeschke: Does the latest commit address your points? > @mroeschke: Does the latest commit address your points?

I don't think this has been addressed yet. https://github.com/pandas-dev/pandas/pull/45765/files#r809553567

The pattern in these classes is for constructor argument to be validated either in `__init__` or `def _validate`. To be consistent it would be good for these `NotImplementedError`s to exist there instead of `BaseIndexer._get_window_bounds` Note that the current test failures appear to be benign (due to `pytest not found`). > > @mroeschke: Does the latest commit address your points?
> 
> I don't think this has been addressed yet. https://github.com/pandas-dev/pandas/pull/45765/files#r809553567
> 
> The pattern in these classes is for constructor argument to be validated either in `__init__` or `def _validate`. To be consistent it would be good for these `NotImplementedError`s to exist there instead of `BaseIndexer._get_window_bounds`

I see. For unsupported step-argument cases, the current version raises `NotImplementedError("step not implemented ...")` already in `rolling.py`, as tested by `test_constructor_step_not_implemented`. Hopefully, raising at these points gives a clear context to the user.

I looked into also raising in the places you noted. AFAICS, the step argument is not available in `pandas/core/indexers/objects.py` before `get_window_bounds` is called. So, raising at constructor time cannot be done there but can be done in `pandas/core/window/rolling.py`, as in the current version. Let me know what you think. Sorry, yes by constructor I was referring to `BaseWindow.__init__/._validate` in `pandas/core/window/rolling.py` > Sorry, yes by constructor I was referring to `BaseWindow.__init__/._validate` in `pandas/core/window/rolling.py`

The current version raises in `rolling.py` at:
- `BaseWindowGroupby.__init__` to handle group-by cases.
- `RollingAndExpandingMixing.cov` and `RollingAndExpandingMixing.corr` to handle cov/corr cases.
- `Rolling._validate` to handle those specific cases of indexers that do not support non-default step arguments.

I'm assuming you want to move the last item to `BaseWindow._validate`. I tried this before and it doesn't work as expected - as the comment marked `GH 15354` in `Rolling._validate` notes, the wrong indexer is being created in `BaseWindow._validate`. Let me know what you think. For exapanding and ewm you can to step validation in those `__init__`s thanks @rtpsw very nice! let's followup as needed