Assigning a DataArray with different shape to Dataset variable does not update the variable
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Bắt đầu bằng cách chạy ví dụ Python tối thiểu với xarray và numpy để xác nhận cách việc gán biến Dataset xử lý chiều code khác nhau. Tìm các bài kiểm thử hoặc phần triển khai phép gán Dataset, thêm một trường hợp hồi quy cho hình dạng và các tọa độ mới, rồi xác minh rằng dataSet['open'] khớp với dataArray_new sau khi gán.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 4.2k
- Fork
- 1.5k
- Merge trung bình
- 2 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 74
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pydata/xarray
-
xarray removes axis grid from pcolormeshCó thể đã có người làm @Sealdot đã nhận hôm nay. Đang mởbug needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
`DataTree.map_over_datasets` behavior can be obscure sometimesCó thể đã có người làm @mohansree14 đã nhận 24 ngày trước. Đang mởneeds triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pydata/xarray#11813 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Comparing attrs that contain a dict of NumPy arrays raises ValueError in identical / assert_identicalCó thể đã có người làm @SohamXYZDev đã nhận 29 ngày trước. Đang mởbug needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
pydata/xarray#11777 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
RangeIndex` with datetime64 bounds cannot be printed (`Unknown format code 'g'`)Có thể đã có người làm @d-chambers đã nhận 60 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
pydata/xarray#11598 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DataTree constructor error message says dict even though dict is not acceptedCó thể đã có người làm @aryansk đã nhận 100 ngày trước. Đang mởbug contrib-good-first-issue topic-DataTree topic-error reporting
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
pydata/xarray#11514 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của pydata/xarray
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
abetlen/llama-cpp-python#2424 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug IronPython Python 3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
pyrevitlabs/pyRevit#4184 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
CLAW (Agents & Orchestration)Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
jqueryscript/awesome-claude-code#1009 ·
-
tests
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày