issues: 603309899
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
603309899 | MDU6SXNzdWU2MDMzMDk4OTk= | 3985 | xarray=1.15.1 regression: Groupby drop multi-index | 8419157 | closed | 0 | 4 | 2020-04-20T15:05:51Z | 2021-02-16T15:59:46Z | 2021-02-16T15:59:46Z | NONE | I have written a function MCVE Code Sample```python import xarray as xr DimensionsN = xr.DataArray(np.arange(100), dims='N', name='N') reps = xr.DataArray(np.arange(5), dims='reps', name='reps') horizon = xr.DataArray([1, -1], dims='horizon', name='horizon') horizon.attrs = {'long_name': 'Horizonal', 'units': 'H'} vertical = xr.DataArray(np.arange(1, 4), dims='vertical', name='vertical') vertical.attrs = {'long_name': 'Vertical', 'units': 'V'} Variablesx = xr.DataArray(np.random.randn(len(N), len(reps), len(horizon), len(vertical)), dims=['N', 'reps', 'horizon', 'vertical'], name='x') y = x * 0.1 y.name = 'y' Merge x, ydata = xr.merge([x, y]) Assign coordsdata = data.assign_coords(reps=reps, vertical=vertical, horizon=horizon) Function that stack all but one diensions and groupby over the stacked dimension.def process_stacked_groupby(ds, dim, func, *args):
Function to apply on groupbydef fn(ds): return ds Run groupby with applied functiondata.pipe(process_stacked_groupby, 'N', fn) ``` Expected OutputPrior to xarray=0.15.0, the above code produce a result that I wanted. The function should be able to 1. stack chosen dimensions 2. groupby the stacked dimension 3. apply a function on each group a. The function actually passes along another function with unstacked group coord b. Add multi-index stacked group coord back to the results of this function 4. combine the groups 5. Unstack stacked dimension Problem DescriptionAfter upgrading to 0.15.1, the above code stopped working.
The error occurred at the line
Versions0.15.1 |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/3985/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |