【发布时间】:2021-02-02 20:33:03
【问题描述】:
我有一个如下所示的 DataArray:
<xarray.DataArray (rows: 3, cols: 3)>
array([[11, 12, 13],
[21, 22, 23],
[31, 32, 33]])
Coordinates:
* rows (rows) <U5 'row1' 'row2' 'row3'
* cols (cols) <U4 'col1' 'col2' 'col3'
如何更改标签以获得:
<xarray.DataArray (rows: 3, cols: 3)>
array([[11, 12, 13],
[21, 22, 23],
[31, 32, 33]])
Coordinates:
* rows (rows) <U5 'rowA' 'rowB' 'rowC'
* cols (cols) <U4 'col1' 'col2' 'col3'
我尝试使用test.rename({"row1":"rowA", "row2":"rowB", "row3":"rowC"}),但它给了我一个ValueError:
ValueError: cannot rename 'row1' because it is not a variable or dimension in this dataset
我认为重命名只是用于维度名称,但如果是这种情况,那么文档并没有明确说明根本。
【问题讨论】: