Skip to content

PandasIndex.create_variables() hot fix. #10518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions xarray/core/indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,8 +786,16 @@ def create_variables(
attrs: Mapping[Hashable, Any] | None
encoding: Mapping[Hashable, Any] | None

if variables is not None and name in variables:
var = variables[name]
if variables is not None:
if name in variables:
var = variables[name]
else:
# temp fix for PandasIndex subclasses that
# do not update self.index.name in the
# (overridden) PandasIndex.from_variables()
assert len(variables) == 1
name, var = next(iter(variables.items()))
self.index.name = name
attrs = var.attrs
encoding = var.encoding
else:
Expand Down
Loading