DataArray .rolling() unclear behaviour when center=False
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
What is your issue?
Hi,
I am using the rolling().construct() method which I found very convenient and efficient.
I had timeseries with 2 dimensions: time and channel. I used the construct to produce small overlapping windows of samples on all channels:
xr_data['full_windowed_eeg'] = xr_data['resampled_eeg'] \
.rolling(resampled_time=window_size, min_periods=None) \
.construct("window_tvec", stride=1, keep_attrs=True) \
.dropna('resampled_time') \
.rename({'resampled_time':'window_time'}).copy()
However, after not obtaining the result I expected, I found out that the new coord window_time, was corresponding to the original time coords at the end/right of the window, and not as the first time coord of the window as I expected.
There is no argument to specify this apparently, as in its current state, it allows only for taking the "center coord" or the "right coord" (if center=False).
I expect that the way I wanted it is not so uncommon, so implementing that possibility would be great. But more urgently, I would find it extremely useful and avoiding puzzling debbugging if this behaviour was clearly explained in the API reference.
But maybe I am missing something here?
Thanks for your great work !
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the rolling().construct() API reference and inspect how center=False assigns the resulting coordinate. Clarify that the coordinate corresponds to the right/end of each window, and document whether selecting the first/left coordinate is supported; done when the behavior and available options are explicit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100