Skip to content

Commit bbd24d5

Browse files
committed
bugfix
1 parent cfcbfc4 commit bbd24d5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

xarray/core/dataset.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,12 +3032,13 @@ def _rename_all(self, name_dict, dims_dict):
30323032
# in this case, convert to IndexVariable and set indexes
30333033
# GH4107
30343034
for name in set(self.dims):
3035-
indexvar = variables.pop(name).to_index_variable()
3036-
variables[name] = indexvar
3037-
if indexes is None:
3038-
indexes = dict()
3039-
indexes[name] = indexvar.to_index()
3040-
coord_names.add(name)
3035+
if name in variables:
3036+
indexvar = variables.pop(name).to_index_variable()
3037+
variables[name] = indexvar
3038+
if indexes is None:
3039+
indexes = dict()
3040+
indexes[name] = indexvar.to_index()
3041+
coord_names.add(name)
30413042

30423043
return variables, coord_names, dims, indexes
30433044

0 commit comments

Comments
 (0)