issues: 256496917
This data as json
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
256496917 | MDU6SXNzdWUyNTY0OTY5MTc= | 1565 | Regression: time attributes on PeriodIndex | 10050469 | open | 0 | 12 | 2017-09-10T09:27:09Z | 2021-07-20T18:33:29Z | MEMBER | The following used to work with xarray 0.9.5 but doesn't anymore with 0.9.6 or master:
```KeyError Traceback (most recent call last) ~/.pyvirtualenvs/py3/lib/python3.5/site-packages/xarray/core/dataarray.py in _getitem_coord(self, key) 458 try: --> 459 var = self._coords[key] 460 except KeyError: KeyError: 'time.month' During handling of the above exception, another exception occurred: AttributeError Traceback (most recent call last) <ipython-input-1-41829b924596> in <module>() 4 time = pd.period_range('2000-01', '2000-12', freq='M') 5 da = xr.DataArray(np.arange(12), dims=['time'], coords={'time':time}) ----> 6 da['time.month'] ~/.pyvirtualenvs/py3/lib/python3.5/site-packages/xarray/core/dataarray.py in getitem(self, key) 467 def getitem(self, key): 468 if isinstance(key, basestring): --> 469 return self._getitem_coord(key) 470 else: 471 # orthogonal array indexing ~/.pyvirtualenvs/py3/lib/python3.5/site-packages/xarray/core/dataarray.py in getitem_coord(self, key) 461 dim_sizes = dict(zip(self.dims, self.shape)) 462 , key, var = _get_virtual_variable( --> 463 self._coords, key, self._level_coords, dim_sizes) 464 465 return self._replace_maybe_drop_dims(var, name=key) ~/.pyvirtualenvs/py3/lib/python3.5/site-packages/xarray/core/dataset.py in _get_virtual_variable(variables, key, level_vars, dim_sizes) 82 data = getattr(ref_var.dt, var_name).data 83 else: ---> 84 data = getattr(ref_var, var_name).data 85 virtual_var = Variable(ref_var.dims, data) 86 AttributeError: 'IndexVariable' object has no attribute 'month' ``` |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/1565/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
13221727 | issue |