id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 163414759,MDU6SXNzdWUxNjM0MTQ3NTk=,894,Dataset variable reference fails after renaming,17951292,closed,0,,,4,2016-07-01T15:04:15Z,2016-08-02T17:39:11Z,2016-08-02T17:39:11Z,NONE,,,,"Using xarray v0.7.2, I've encountered what looks to be a bug whereby referencing a re-named variable raises a KeyError: # compute anomalies climo = ds.groupby('time.dayofyear').mean('time') anom = ds.groupby('time.dayofyear') - climo anom.rename({'air': 't2manom'}) **# Output** _ Dimensions: (lat: 37, level: 1, lon: 192, time: 13514) Coordinates: - lat (lat) float32 88.542 86.6531 84.7532 82.8508 80.9473 79.0435 ... - level (level) float32 2.0 - lon (lon) float32 0.0 1.875 3.75 5.625 7.5 9.375 11.25 13.125 ... dayofyear (time) int32 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... - time (time) datetime64[ns] 1979-01-01 1979-01-02 1979-01-03 ... Data variables: t2manom (time, level, lat, lon) float64 -6.342 -6.476 -6.522 -6.579 ..._ anom['t2manom'].values[0:5] **Output:** _--------------------------------------------------------------------------- KeyError Traceback (most recent call last) in () 8 #del normalized['dayofyear'] 9 #normalized ---> 10 anom['t2manom'].values[0:5] /usr/local/lib/python2.7/dist-packages/xarray/core/dataset.pyc in **getitem**(self, key) 527 528 if hashable(key): --> 529 return self._construct_dataarray(key) 530 else: 531 return self._copy_listed(np.asarray(key)) /usr/local/lib/python2.7/dist-packages/xarray/core/dataset.pyc in _construct_dataarray(self, name) 476 variable = self._variables[name] 477 except KeyError: --> 478 _, name, variable = _get_virtual_variable(self._variables, name) 479 480 coords = OrderedDict() /usr/local/lib/python2.7/dist-packages/xarray/core/dataset.pyc in _get_virtual_variable(variables, key) 43 split_key = key.split('.', 1) 44 if len(split_key) != 2: ---> 45 raise KeyError(key) 46 47 ref_name, var_name = split_key KeyError: 't2manom'_ However, referencing the OLD variable name ('air' in this case) produces the output expected when referencing the NEW variable name: anom['air'].values[0:5] **Output:** array([[[[ -6.34243229, -6.47621607, -6.52189175, ..., -6.3105404 , -6.33972959, -6.30999986], [ -9.18891871, -9.32432412, -9.57216195, ..., -8.67081062, -8.89675656, -9.09081061], [ -8.8072971 , -9.27054033, -9.69972951, ..., -7.53378362, -7.93783766, -8.3737836 ], ..., [ -4.30864855, -3.5656756 , -1.10594592, ..., -1.70405402, -2.53135129, -2.92999993], [ -1.197027 , -1.34837835, -0.5481081 , ..., 0.01810811, 0.01540541, -0.62756755], [ 0.47135134, 0.22297297, -0.50756756, ..., 0.63297296, 0.65837836, 0.58891891]]], [...omitted values...] Am I doing something wrong here? ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/894/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue