Inconsistent and unexpected results when grouping by more than one coordinate
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
Línea de trabajo
Empieza ejecutando el MVCE proporcionado y compara groupby(["test1", "test2"]) con el caso funcional de coordenadas en tupla. Sigue el punto de entrada de groupby y cómo gestiona múltiples coordenadas; se considera terminado cuando la agrupación utiliza únicamente combinaciones de coordenadas observadas y el comportamiento está cubierto por una prueba de regresión.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Python
- Estrellas
- 4.2k
- Forks
- 1.5k
- Merge medio
- 2 d 20 h
- PR fusionados (30 d)
- 70
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de pydata/xarray
-
xarray removes axis grid from pcolormeshPosiblemente ocupada @Sealdot la tomó hace 1 día. Abiertobug needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
`DataTree.map_over_datasets` behavior can be obscure sometimesPosiblemente ocupada @mohansree14 la tomó hace 24 días. Abiertoneeds triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
pydata/xarray#11813 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Comparing attrs that contain a dict of NumPy arrays raises ValueError in identical / assert_identicalPosiblemente ocupada @SohamXYZDev la tomó hace 30 días. Abiertobug needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
pydata/xarray#11777 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
RangeIndex` with datetime64 bounds cannot be printed (`Unknown format code 'g'`)Posiblemente ocupada @d-chambers la tomó hace 61 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
pydata/xarray#11598 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
DataTree constructor error message says dict even though dict is not acceptedPosiblemente ocupada @aryansk la tomó hace 100 días. Abiertobug contrib-good-first-issue topic-DataTree topic-error reporting
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
pydata/xarray#11514 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de pydata/xarray
Issues similares
-
documentation priority: low size: S status: needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
cubrid-lab/sqlalchemy-cubrid#1397 ·
Los mantenedores suelen responder en 1 día
-
documentation priority: low size: S status: needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
cubrid-lab/pycubrid#1307 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: Installer hides SSL certificate errors as bare URLError, and the suggested fix can't workAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
ShaftHQ/chaosengine-harness#143 ·
Los mantenedores suelen responder en 1 día
-
LLMContextNode tool builders fail on nested params like `params:retrieval.max_matches`Posiblemente ocupada @Shizoqua la tomó hoy. AbiertoCommunity
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 2 días
-
security
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
btclib-org/portanode#985 ·
Los mantenedores suelen responder en 1 día