Assigning a DataArray with different shape to Dataset variable does not update the variable
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Inizia eseguendo l'esempio Python minimale con xarray e numpy per confermare come l'assegnazione delle variabili di Dataset gestisce la diversa dimensione code. Individua i test o l'implementazione dell'assegnazione di Dataset, aggiungi un caso di regressione per la nuova forma e le coordinate e verifica che dataSet['open'] corrisponda a dataArray_new dopo l'assegnazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happened?
I encountered an issue when trying to assign a new DataArray to an existing variable in an xarray Dataset. The assignment appears to not update the variable as expected.
Here is a minimal example that reproduces the problem:
What did you expect to happen?
After the assignment, dataSet['open']should have the same data and coordinates as dataArray_new, i.e., shape (3,3) with codes ['000123', '000456', '000111'].
Minimal Complete Verifiable Example
import xarray as xr
import numpy as np
DataTime=[20260102,20260103,20260104]
codes = ['000123', '000456']
dataArray = xr.DataArray(
np.random.randn(len(DataTime), len(codes)),
dims=['time', 'code'],
coords={'code': codes,'time': DataTime}
)
dataArray_new = xr.DataArray(
np.random.randn(len(DataTime), 3),
dims=['time', 'code'],
coords={'code': ['000123', '000456','000111'],'time': DataTime}
)
dataSet = xr.Dataset({'open': dataArray})
dataSet['open']=dataArray_new
print(dataSet['open'])
print()
print(dataArray_new)
print("xarray version",xr.__version__)
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
output:
Python 3.13.7 (tags/v3.13.7:bcee1c3, Aug 14 2025, 14:15:11) [MSC v.1944 64 bit (AMD64)] on win32
Enter "help" below or click "Help" above for more information.
= RESTART: C:/Users/Administrator/AppData/Local/Programs/Python/Python313/delok.py
<xarray.DataArray 'open' (time: 3, code: 2)> Size: 48B
array([[ 0.00311068, -1.68021968],
[ 0.23174369, 1.72308605],
[ 0.05651745, -0.07747445]])
Coordinates:
time (time) int64 24B 20260102 20260103 20260104
code (code) <U6 48B '000123' '000456'
<xarray.DataArray (time: 3, code: 3)> Size: 72B
array([[ 0.00311068, -1.68021968, -1.19742281],
[ 0.23174369, 1.72308605, -1.11061083],
[ 0.05651745, -0.07747445, 0.70037003]])
Coordinates:
time (time) int64 24B 20260102 20260103 20260104
code (code) <U6 72B '000123' '000456' '000111'
xarray version 2026.1.0
Anything else we need to know?
No response
Environment
- Lingua principale
- Python
- Stelle
- 4.2k
- Fork
- 1.5k
- Merge medio
- 2g 21h
- PR unite (30g)
- 74
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pydata/xarray
-
xarray removes axis grid from pcolormeshForse già presa @Sealdot l’ha presa oggi. Apertabug needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
`DataTree.map_over_datasets` behavior can be obscure sometimesForse già presa @mohansree14 l’ha presa 24 giorni fa. Apertaneeds triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
pydata/xarray#11813 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Comparing attrs that contain a dict of NumPy arrays raises ValueError in identical / assert_identicalForse già presa @SohamXYZDev l’ha presa 29 giorni fa. Apertabug needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
pydata/xarray#11777 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
RangeIndex` with datetime64 bounds cannot be printed (`Unknown format code 'g'`)Forse già presa @d-chambers l’ha presa 60 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
pydata/xarray#11598 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
DataTree constructor error message says dict even though dict is not acceptedForse già presa @aryansk l’ha presa 100 giorni fa. Apertabug contrib-good-first-issue topic-DataTree topic-error reporting
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
pydata/xarray#11514 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di pydata/xarray
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
abetlen/llama-cpp-python#2424 ·
I maintainer di solito rispondono entro 1 giorno
-
Bug IronPython Python 3
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
pyrevitlabs/pyRevit#4184 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 74/100
jqueryscript/awesome-claude-code#1009 ·
-
tests
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno