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/1519#issuecomment-1114798980,https://api.github.com/repos/pydata/xarray/issues/1519,1114798980,IC_kwDOAMm_X85CcnuE,26384082,2022-05-02T12:37:49Z,2022-05-02T12:37:49Z,NONE,"In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity
If this issue remains relevant, please comment here or remove the `stale` label; otherwise it will be marked as closed automatically
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,252490115
https://github.com/pydata/xarray/issues/1519#issuecomment-611501372,https://api.github.com/repos/pydata/xarray/issues/1519,611501372,MDEyOklzc3VlQ29tbWVudDYxMTUwMTM3Mg==,2448579,2020-04-09T12:29:53Z,2020-04-09T12:29:53Z,MEMBER,How does this even work? :scream:,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,252490115
https://github.com/pydata/xarray/issues/1519#issuecomment-611480620,https://api.github.com/repos/pydata/xarray/issues/1519,611480620,MDEyOklzc3VlQ29tbWVudDYxMTQ4MDYyMA==,14808389,2020-04-09T11:34:57Z,2020-04-09T11:34:57Z,MEMBER,"since it came up in #3939, I played around with this, and it seems the `obj.sel(x=1)[...] = 0` syntax only works for `DataArray` objects and when assigning a single value. Should we try to make it work the same way as `loc`?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,252490115
https://github.com/pydata/xarray/issues/1519#issuecomment-604553156,https://api.github.com/repos/pydata/xarray/issues/1519,604553156,MDEyOklzc3VlQ29tbWVudDYwNDU1MzE1Ng==,14808389,2020-03-26T17:07:42Z,2020-03-26T17:50:49Z,MEMBER,"it's not that it fails, the original dataset is just not updated:
```python
In [2]: ds = xr.Dataset({
...: ""a"": (""x"", np.arange(4)),
...: ""b"": (""x"", np.arange(4)),
...: })
In [3]: selected = ds.loc[{""x"": 1}]
...: selected[""a""] = 10
...: ds, selected
Out[3]:
(
Dimensions: (x: 4)
Dimensions without coordinates: x
Data variables:
a (x) int64 0 1 2 3
b (x) int64 0 1 2 3,
Dimensions: ()
Data variables:
a int64 10
b int64 1)
```
to make it work, use (note the `[...]`)
```python
In [7]: selected = ds.loc[{""x"": 1}]
...: selected[""a""][...] = 10
...: ds, selected
Out[7]:
(
Dimensions: (x: 4)
Dimensions without coordinates: x
Data variables:
a (x) int64 0 10 2 3
b (x) int64 0 1 2 3,
Dimensions: ()
Data variables:
a int64 10
b int64 1)
```
The difference is that without the extra `[...]` we don't modify the values but instead create a new variable (so something like `ds[""new_variable""] = (""x"", [1, 3, 4, 5])`)
Also note that while `ds.a.sel(x=1) = 10` raises a `SyntaxError`, `ds.a.sel(x=1)[...] = 10` or `ds.sel(x=1).a[...] = 10` have exactly the same effect as their `loc` counterparts.
We probably should add an explanation and examples to the documentation (`loc` / `sel` and maybe the `indexing` page?)","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,252490115
https://github.com/pydata/xarray/issues/1519#issuecomment-604562843,https://api.github.com/repos/pydata/xarray/issues/1519,604562843,MDEyOklzc3VlQ29tbWVudDYwNDU2Mjg0Mw==,14808389,2020-03-26T17:24:20Z,2020-03-26T17:24:20Z,MEMBER,"also, we can't really raise only for `ds.loc[...][name] = -1` since for python that is the same as
```python
intermediate_ds = ds.loc[...]
intermediate_ds[name] = -1
```
where the second line is something we explicitly want to support.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,252490115
https://github.com/pydata/xarray/issues/1519#issuecomment-604543399,https://api.github.com/repos/pydata/xarray/issues/1519,604543399,MDEyOklzc3VlQ29tbWVudDYwNDU0MzM5OQ==,6980561,2020-03-26T16:50:44Z,2020-03-26T16:50:44Z,NONE,"I'm re-pinging this issue since I was just bitten by it (on version 0.15).
If creating an exception is time consuming could we instead have a disclaimer regarding this behavior to the documentation? Here's a basic working example that shows that it does silently fail:
```
# Basic working example of the silently failing indexing assignment
ds = xr.Dataset({'a': (('x'), np.arange(4)),
'b': (('x'), np.arange(4))
})
# Silently fails assignment
ds.loc[{'x': 1}]['a'] = 10
print(ds)
# Works as intended
ds['a'].loc[{'x': 1}] = 10
print(ds)
```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,252490115