Inconsistent and unexpected results when grouping by more than one coordinate
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 55/100
調査の方向性
まず、提供された MVCE を実行し、groupby(["test1", "test2"]) と、動作するタプル座標のケースを比較します。groupby のエントリポイントと複数の座標の処理を追跡します。グループ化が観測された座標の組み合わせだけを使用し、その動作が回帰テストでカバーされれば完了です。
索引モデルが issue の本文から書いたものです。
説明
What happened?
Grouping by more than one coordinate uses all combinations of coordinates.
What did you expect to happen?
I would expect only the observed combinations to be used.
Minimal Complete Verifiable Example
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "xarray[complete]@git+https://github.com/pydata/xarray.git@main",
# ]
# ///
#
# This script automatically imports the development branch of xarray to check for issues.
# Please delete this header if you have _not_ tested this script with `uv run`!
import xarray as xr
xr.show_versions()
import numpy as np
import pandas as pd
df = pd.DataFrame(data=dict(test1=[1, 2, 3, 4, 5], test2=[1, 1, 1, 2, 2]))
df['test3'] = df[['test1', 'test2']].apply(tuple, axis=1)
coords = {}
for c in df.columns:
coords[c] = ("y", df[c].values)
d = xr.DataArray(np.ones((5, 5)), dims=("y", "x"), coords=coords)
d.groupby(["test1", "test2"]).mean() # generate all combinations of test1 and test2
d.groupby("test3").mean() # works as expected
# NotImplementedError
# d.set_xindex(["test1", "test2"], PandasMultiIndex).groupby(["test1", "test2"]).mean()
Steps to reproduce
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.
- Recent environment — the issue occurs with the latest version of xarray and its dependencies.
Relevant log output
Anything else we need to know?
No response
Environment
INSTALLED VERSIONS
commit: None
python: 3.12.12 | packaged by conda-forge | (main, Jan 27 2026, 00:01:15) [Clang 19.1.7 ]
python-bits: 64
OS: Darwin
OS-release: 25.3.0
machine: arm64
processor: arm
byteorder: little
LC_ALL: None
LANG: C.UTF-8
LOCALE: ('C', 'UTF-8')
libhdf5: 1.14.6
libnetcdf: None
xarray: 2026.2.0
pandas: 2.3.3
numpy: 2.4.3
scipy: 1.17.1
netCDF4: None
pydap: None
h5netcdf: 1.8.1
h5py: 3.14.0
zarr: 2.18.7
cftime: None
nc_time_axis: None
iris: None
bottleneck: None
dask: 2025.11.0
distributed: 2025.11.0
matplotlib: 3.10.8
cartopy: None
seaborn: 0.13.2
numbagg: None
fsspec: 2026.2.0
cupy: None
pint: 0.25.2
sparse: 0.18.0
flox: 0.11.2
numpy_groupies: 0.11.3
setuptools: 82.0.1
pip: 26.0.1
conda: None
pytest: 9.0.2
mypy: None
IPython: 9.10.0
sphinx: None
- 主要言語
- Python
- スター
- 4.2k
- フォーク
- 1.5k
- 平均マージ
- 2日 20時間
- マージ済み PR(30日)
- 70
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pydata/xarray のほかの issue
-
xarray removes axis grid from pcolormesh対応中かも @Sealdot が 1 日前に担当しました。 オープンbug needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
`DataTree.map_over_datasets` behavior can be obscure sometimes対応中かも @mohansree14 が 24 日前に担当しました。 オープンneeds triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
pydata/xarray#11813 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Comparing attrs that contain a dict of NumPy arrays raises ValueError in identical / assert_identical対応中かも @SohamXYZDev が 30 日前に担当しました。 オープンbug needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
pydata/xarray#11777 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
RangeIndex` with datetime64 bounds cannot be printed (`Unknown format code 'g'`)対応中かも @d-chambers が 61 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
pydata/xarray#11598 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
DataTree constructor error message says dict even though dict is not accepted対応中かも @aryansk が 100 日前に担当しました。 オープンbug contrib-good-first-issue topic-DataTree topic-error reporting
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
pydata/xarray#11514 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
documentation priority: low size: S status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
cubrid-lab/sqlalchemy-cubrid#1397 ·
メンテナーはふだん 1 日以内に返信
-
documentation priority: low size: S status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
cubrid-lab/pycubrid#1307 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: Installer hides SSL certificate errors as bare URLError, and the suggested fix can't workオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
ShaftHQ/chaosengine-harness#143 ·
メンテナーはふだん 1 日以内に返信
-
LLMContextNode tool builders fail on nested params like `params:retrieval.max_matches`対応中かも @Shizoqua が今日担当しました。 オープンCommunity
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
-
security
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
btclib-org/portanode#985 ·
メンテナーはふだん 1 日以内に返信