How to rename a single coordinate in a DataArray? #9097
Replies: 3 comments
-
Rename changes the name of the array. I think you want a |
Beta Was this translation helpful? Give feedback.
-
Not exactly - a "coordinate" refers to the entire |
Beta Was this translation helpful? Give feedback.
-
@jaxengodfrey for your example of replacing a specific value along a dimension (
|
Beta Was this translation helpful? Give feedback.
-
Hello all,
I'm trying to use
xarray.DataArray.rename
to rename a specific coordinate of an existing DataArray. The documentation page says to pass "a mapping from old names to new names for coordinates or dimensions". However, when I do this for a specific coordinate value, rather than a dimension, it throws an error. Bellow is an example of what I'm attempting to do:which throws this error:
I know I could use
assign_coords
instead, but it requires passing in the entire coordinate list, which I'd like to avoid doing since I'm only updating one coordinate. I may also be misunderstanding the terminology, but I believe a "coordinate" refers to a specific value along a given dimension, so based on the doc page forrename
, what I'm trying to do should work. If anyone could point me in the right direction, I would really appreciate it!Beta Was this translation helpful? Give feedback.
All reactions