Future of `DataArray.rename`
See original GitHub issueWhat is your issue?
In https://github.com/pydata/xarray/pull/6665 the question came up what to do with DataArray.rename
in light of the new index refactor.
To be consistent with Dataset
we should introduce a
DataArray.rename_dims
DataArray.rename_vars
DataArray.rename
Several open questions about the behavior (Similar things apply to Dataset.rename{, _dims, _vars}
):
- Should
rename_dims
also rename indexes (dimension coordinates)? - Should
rename_vars
also rename the DataArray? - What to do if the
DataArray
has the same name as one of its coordinates? - Should
rename
still rename everything (like it is now) or only the name (Possibly with some deprecation cycle)?
The current implementation of DataArray.rename
is a bit inconsistent:
As stated by @max-sixty in https://github.com/pydata/xarray/issues/6665#issuecomment-1154368202_:
- rename operates on DataArray as described in https://github.com/pydata/xarray/pull/6665#issuecomment-1150810485. Generally I’m less keen on “different types have different semantics”, and here a positional arg would mean a DataArray rename, and kwarg would mean var rename. But it does work locally to DataArray quite well.
- rename only exists on DataArrays for the name of the DataArray, and we use rename_vars & rename_dims for both DataArrays & Datasets. So Dataset.rename is soft-deprecated.
Issue Analytics
- State:
- Created a year ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
xarray.DataArray.rename
Returns a new DataArray with renamed coordinates, dimensions or a new name. ... Last updated on 2022-12-02. Xarray is a fiscally sponsored project...
Read more >Dataset — MIKE IO documentation - GitHub Pages
The mikeio.read() methods returns a Dataset as a container of DataArrays ... It will be extended in the future. ... Rename items (DataArrays)...
Read more >python-xarray copy mask from one DataArray to another
You will need to explicitly rename dimension names to match, e.g., hs = hs.rename({'lat': 'latitude', 'longitude': 'longitude'}) .
Read more >python-xarray-0.11.3-bp152.3.25 - SUSE Package Hub -
Future releases will be Python 3 only, but older versions of xarray will always be ... :py:meth:`~DataArray.rename` now supports supplying **kwargs, ...
Read more >CRIB: Consolidated Rename, Issue, and Bypass - PHARM
line-free approach that consolidates rename, issue, and bypass logic ... organization for future processors. ... Tag Array. Data Array ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I feel honored thanks! But given that I will become a father any day now, I don’t think I will be able to join regularly…
that’s #4001