home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 479389904

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/2854#issuecomment-479389904 https://api.github.com/repos/pydata/xarray/issues/2854 479389904 MDEyOklzc3VlQ29tbWVudDQ3OTM4OTkwNA== 10050469 2019-04-03T08:23:51Z 2019-04-03T08:23:51Z MEMBER

This is puzzling. I've edited the example a bit for clarity, but I have no clue what's going on:

```python import numpy as np import xarray as xr

da = xr.DataArray(np.random.random((3, 4)), dims=["assets", "year"], coords={"year": range(2010, 2018, 2)}, name='var' )

Interpolate directly the DataArray

new_da = da.interp(year=[2011, 2015])

Interpolate via dataset

new_ds = xr.Dataset({"var": da.copy()}).interp(year=[2011, 2015])['var']

Equivalent DAs

xr.testing.assert_identical(new_da, new_ds)

Indexing works

xr.testing.assert_identical(new_da.loc[{"year": 2015}], new_ds.loc[{"year": 2015}])

Assignment doesn't

new_da.loc[{"year": 2015}] = 42 new_ds.loc[{"year": 2015}] = 42 # Fails


IndexError Traceback (most recent call last) <ipython-input-35-65ad561f1692> in <module>() 21 # Assignment doesn't 22 new_da.loc[{"year": 2015}] = 42 ---> 23 new_ds.loc[{"year": 2015}] = 42 # Fails

....

~/Documents/git/xarray/xarray/core/indexing.py in getitem(self, key) 1168 def getitem(self, key): 1169 array, key = self._indexing_array_and_key(key) -> 1170 return array[key] 1171 1172 def setitem(self, key, value):

IndexError: index 2015 is out of bounds for axis 0 with size 2 ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  425905002
Powered by Datasette · Queries took 0.735ms · About: xarray-datasette