Add a drop_outer option to .where()

Abierto
#11,883 1 comentario 0 reacciones 0 asignados Ver en GitHub

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
48/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
data

Línea de trabajo

Start by reading the implementation and tests for .where() to understand how drop=True currently handles coordinate labels. Then assess how an outer-only trim could preserve internal NaN gaps and coordinate spacing; the issue does not name specific files or tests. Done means a drop_outer option trims only outer all-NaN regions while retaining internal gaps.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

enhancement
Is your feature request related to a problem?

Currently, .where() supports drop=True, which removes coordinate labels where all values are NaN. However, this also removes internal rows or columns of NaN values, which can disrupt the structure of regularly spaced arrays.

Describe the solution you'd like

It would be useful to have an additional option, perhaps drop_outer=True, which only removes outer coordinate labels where all values are NaN, effectively trimming the array to the smallest bounding region containing valid data while preserving internal gaps and coordinate spacing.

Describe alternatives you've considered

This is relatively easy to achieve using .isel(dim=slice(...)) after calling .where() with drop=False, but it would be very helpful to have this functionality built into .where().

Additional context

No response

Lenguaje dominante
Python
Estrellas
4.2k
Forks
1.5k
Merge medio
2 d 21 h
PR fusionados (30 d)
74

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de pydata/xarray

Todos los issues de pydata/xarray

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.