home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 546791416

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
546791416 MDU6SXNzdWU1NDY3OTE0MTY= 3671 rolling.construct alignment 12862013 closed 0     4 2020-01-08T11:03:28Z 2020-01-11T02:24:21Z 2020-01-11T02:24:21Z CONTRIBUTOR      

Hello xarray team

I was trying to implement functionality similar to Scikit Image's view_as_windows, but I was having a hard time with the boundary conditions. I understand this request is very similar to rolling with periodic boundary conditions #2007.

MCVE Code Sample

```python

arr = xr.DataArray(np.arange(4), dims=("x",)) arr.rolling(x=2).construct("roll_x", stride=2) <xarray.DataArray (x: 2, roll_x: 2)> array([[nan, 0.], [ 1., 2.]]) Dimensions without coordinates: x, roll_x ```

Expected Output

It would be nice to be able to easily get an output of: python <xarray.DataArray (x: 2, roll_x: 2)> array([[0., 1.], [2., 3.]]) Dimensions without coordinates: x, roll_x

Possible workarounds

With the upcoming features of pad (#3596) and rolling: periodic (#2011) it is actually not that hard to work around with:

```python arr.pad(x=(1,0)).rolling(x=2).construct("roll_x", stride=2).isel(x=slice(1,None))

or

arr.roll(x=-1).rolling(x=2, boundary="periodic").construct("roll_x", stride=2) ```

Idea

Would it be possible to add a keyword argument to either rolling() or construct() that expects an alignment of "left", "right" or "center". I understand that this could break interface copied from Pandas, but I hope it could be useful to others as well.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3671/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 4 rows from issue in issue_comments
Powered by Datasette · Queries took 156.691ms · About: xarray-datasette