question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Future of `DataArray.rename`

See original GitHub issue

What 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:open
  • Created a year ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
headtr1ckcommented, Jun 21, 2022

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…

1reaction
keewiscommented, Jun 19, 2022

that’s #4001

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found