home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 1888573893

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
1888573893 I_kwDOAMm_X85wkVnF 8161 groupby bug 6420873 closed 0     2 2023-09-09T04:38:48Z 2023-09-13T20:03:52Z 2023-09-13T20:03:52Z NONE      

What happened?

Sometimes, when performing a groupby operation on a multidimensional data array, it can return unexpected results.

A copy of the test data could be found here.

Code to reproduce the bug: import xarray as xr ds = xr.open_dataarray('test1.nc').load() ds is a 100x86x25x66 array

amoc1 = ds.isel(member_id=range(50)).stack(mb_time=['member_id', 'time']) amoc1 = amoc1.groupby('mb_time').max(...) amoc1 = amoc1.unstack() amoc1 performing groupby on the first 50 members, results look fine.

amoc2 = ds.isel(member_id=range(50, 100)).stack(mb_time=['member_id', 'time']) amoc2 = amoc2.groupby('mb_time').max(...) amoc2 = amoc2.unstack() amoc2 performing groupby on the last 50 members, results look fine as well.

amoc = ds.isel(member_id=range(0, 100)).stack(mb_time=['member_id', 'time']) amoc = amoc.groupby('mb_time').max(...) amoc = amoc.unstack() amoc performing groupby on the whole 100 members, results look weird.

What did you expect to happen?

No response

Minimal Complete Verifiable Example

No response

MVCE confirmation

  • [ ] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • [ ] Complete example — the example is self-contained, including all data and the text of any traceback.
  • [ ] Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • [ ] New issue — a search of GitHub Issues suggests this is not a duplicate.

Relevant log output

No response

Anything else we need to know?

No response

Environment

INSTALLED VERSIONS ------------------ commit: None python: 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32) [GCC 12.3.0] python-bits: 64 OS: Linux OS-release: 3.10.0-1127.18.2.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: en_US.UTF-8 LANG: en_US.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: 1.12.1 libnetcdf: 4.8.1 xarray: 2023.7.0 pandas: 1.5.3 numpy: 1.24.4 scipy: 1.10.1 netCDF4: 1.6.2 pydap: installed h5netcdf: 1.0.0 h5py: 3.7.0 Nio: None zarr: 2.12.0 cftime: 1.6.2 nc_time_axis: 1.4.1 PseudoNetCDF: None iris: None bottleneck: 1.3.7 dask: 2023.7.1 distributed: 2023.7.1 matplotlib: 3.4.3 cartopy: 0.20.2 seaborn: 0.11.2 numbagg: None fsspec: 2022.11.0 cupy: None pint: 0.19.2 sparse: None flox: None numpy_groupies: None setuptools: 68.0.0 pip: 22.1.2 conda: 23.3.1 pytest: None mypy: None IPython: 7.33.0 sphinx: 5.0.1
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/8161/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  not_planned 13221727 issue

Links from other tables

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