如何在 Xarray 中添加另一个坐标标签?
我有一个 Xarray,说
da = xr.DataArray([[1,2],[1,2]],coords={'x':['param1','param2'],'y':['idx','idx2']})
这是一个 2D 数据数组。 当我构建代码时,我想向这个 2D 数据集添加另一个“列”或坐标标签。类似于在 Pandas 中我可以
da['param3'] = [1,2]
添加其他列。 Xarray中有等效的方法吗?
I have an Xarray, say
da = xr.DataArray([[1,2],[1,2]],coords={'x':['param1','param2'],'y':['idx','idx2']})
This is a 2D data array. As I build out my code, I would like to add another "column" or coordinate label to this 2D dataset. Similar to how in Pandas I can just do
da['param3'] = [1,2]
To add that other column. Is there an equivalent method in Xarray?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我首先使用新数据创建第二个 dataArray:
然后将它们组合起来
你会得到
I would first create a second dataArray with the new data:
then combine them
You get