Skip to content

Commit 762b570

Browse files
committed
bugfix
1 parent 8cca190 commit 762b570

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

xarray/core/dataset.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2900,12 +2900,13 @@ def _rename_all(self, name_dict, dims_dict):
29002900
# in this case, convert to IndexVariable and set indexes
29012901
# GH4107
29022902
for name in set(self.dims):
2903-
indexvar = variables.pop(name).to_index_variable()
2904-
variables[name] = indexvar
2905-
if indexes is None:
2906-
indexes = dict()
2907-
indexes[name] = indexvar.to_index()
2908-
coord_names.add(name)
2903+
if name in variables:
2904+
indexvar = variables.pop(name).to_index_variable()
2905+
variables[name] = indexvar
2906+
if indexes is None:
2907+
indexes = dict()
2908+
indexes[name] = indexvar.to_index()
2909+
coord_names.add(name)
29092910

29102911
return variables, coord_names, dims, indexes
29112912

@@ -5806,6 +5807,7 @@ def filter_by_attrs(self, **kwargs):
58065807
Examples
58075808
--------
58085809
>>> # Create an example dataset:
5810+
...
58095811
>>> import numpy as np
58105812
>>> import pandas as pd
58115813
>>> import xarray as xr
@@ -5986,6 +5988,7 @@ def map_blocks(
59865988
... gb = da.groupby(groupby_type)
59875989
... clim = gb.mean(dim="time")
59885990
... return gb - clim
5991+
...
59895992
>>> time = xr.cftime_range("1990-01", "1992-01", freq="M")
59905993
>>> month = xr.DataArray(time.month, coords={"time": time}, dims=["time"])
59915994
>>> np.random.seed(123)

0 commit comments

Comments
 (0)