Skip to content

Don't emit a warning with .rename if it is a no-op #8265

@hoxbro

Description

@hoxbro

What is your issue?

When running this code:

import xarray as xr
ds = xr.tutorial.load_dataset("rasm")
ds.rename({"time": "time"})

I will get the following warning:

UserWarning: rename 'time' to 'time' does not create an index anymore. Try using swap_dims instead or use set_index after rename to create an indexed coordinate.
  ds.rename({"time": "time"})

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions