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/2055#issuecomment-385016657,https://api.github.com/repos/pydata/xarray/issues/2055,385016657,MDEyOklzc3VlQ29tbWVudDM4NTAxNjY1Nw==,8453445,2018-04-27T16:04:12Z,2018-04-27T16:04:12Z,CONTRIBUTOR,"Great, will do.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,314239017
https://github.com/pydata/xarray/issues/2055#issuecomment-385016272,https://api.github.com/repos/pydata/xarray/issues/2055,385016272,MDEyOklzc3VlQ29tbWVudDM4NTAxNjI3Mg==,8453445,2018-04-27T16:02:44Z,2018-04-27T16:02:44Z,CONTRIBUTOR,"> The where example might be better added to the section on where: http://xarray.pydata.org/en/v0.10.3/indexing.html#masking-with-where
I think this is not correct. the where you linked (or at least the way it is used) is for [masking](http://xarray.pydata.org/en/v0.10.3/generated/xarray.DataArray.where.html#xarray.DataArray.where).
In my example uses [xarray.where()](http://xarray.pydata.org/en/v0.10.3/generated/xarray.where.html) to assign values.
but again, I might be off, i have a limited understanding of this.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,314239017
https://github.com/pydata/xarray/issues/2055#issuecomment-385011095,https://api.github.com/repos/pydata/xarray/issues/2055,385011095,MDEyOklzc3VlQ29tbWVudDM4NTAxMTA5NQ==,1217238,2018-04-27T15:46:01Z,2018-04-27T15:46:01Z,MEMBER,"Actually, on further consideration it is probably best to organize the narrative documentation by task/goal (user need), rather than xarray's internal organization of methods (the API docs are for this). So integrating this in the section on ""Assigning values with indexing"" makes sense for both of these.
Feel free to reorganize the existing material. I think showing how to assign with `.loc` is more important than combined indexing with in-place arithmetic, for example.","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,314239017
https://github.com/pydata/xarray/issues/2055#issuecomment-385009416,https://api.github.com/repos/pydata/xarray/issues/2055,385009416,MDEyOklzc3VlQ29tbWVudDM4NTAwOTQxNg==,1217238,2018-04-27T15:41:34Z,2018-04-27T15:41:34Z,MEMBER,"@chiaral Yes, I think that would be a good place to add the example of assigning with `.loc`.
The `where` example might be better added to the section on where: http://xarray.pydata.org/en/v0.10.3/indexing.html#masking-with-where","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,314239017
https://github.com/pydata/xarray/issues/2055#issuecomment-385000519,https://api.github.com/repos/pydata/xarray/issues/2055,385000519,MDEyOklzc3VlQ29tbWVudDM4NTAwMDUxOQ==,8453445,2018-04-27T15:12:39Z,2018-04-27T15:12:39Z,CONTRIBUTOR,"For example, using the tutorial data:
```
ds = xr.tutorial.load_dataset('air_temperature')
#add an empty 2D dataarray
ds['empty']= xr.full_like(ds.air.mean('time'),fill_value=0)
#modify one grid point, using where() or loc()
ds['empty'] = xr.where((ds.coords['lat']==20)&(ds.coords['lon']==260), 100, ds['empty'])
ds['empty'].loc[dict(lon=260, lat=30)] = 100
#modify an area with where() and a mask
mask = (ds.coords['lat']>20)&(ds.coords['lat']<60)&(ds.coords['lon']>220)&(ds.coords['lon']<260)
ds['empty'] = xr.where(mask, 100, ds['empty'])
#modify an area with loc()
lc = ds.coords['lon']
la = ds.coords['lat']
ds['empty'].loc[dict(lon=lc[(lc>220)&(lc<260)], lat=la[(la>20)&(la<60)])] = 100
```
these are examples that I am pretty sure are not on the website, they are I think common in climate scientists workflow, and that it took me quite a while to figure out. I was using a boolean dataarray as well as in the SO example, slowing down my work of quite a bit.
Do they make sense? I can try and add them to the documentation at [Assigning Values with indexing](http://xarray.pydata.org/en/stable/indexing.html#assigning-values-with-indexing) , or is there another place that is more relevant? ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,314239017
https://github.com/pydata/xarray/issues/2055#issuecomment-384989608,https://api.github.com/repos/pydata/xarray/issues/2055,384989608,MDEyOklzc3VlQ29tbWVudDM4NDk4OTYwOA==,8453445,2018-04-27T14:36:45Z,2018-04-27T14:36:45Z,CONTRIBUTOR,"I finally had the time to try out this SO suggestion on assigning on multiple dimensions as well (imaging being in need to modify the forcing of a model for a selected area) and it works. These are quite peculiar ways (at least for people not deep into xarray...) to assign values; I am compiling a list of them which IMHO should be added somewhere in the help. I will post them here for discussion, and to make sure they are indeed the most correct way to do it!
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,314239017
https://github.com/pydata/xarray/issues/2055#issuecomment-382482737,https://api.github.com/repos/pydata/xarray/issues/2055,382482737,MDEyOklzc3VlQ29tbWVudDM4MjQ4MjczNw==,1217238,2018-04-18T18:23:21Z,2018-04-18T18:23:21Z,MEMBER,"This just came up again on StackOverflow:
https://stackoverflow.com/questions/49905351/assigning-particular-elements-of-dataarray-based-on-another/49906534#49906534","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,314239017
https://github.com/pydata/xarray/issues/2055#issuecomment-381267240,https://api.github.com/repos/pydata/xarray/issues/2055,381267240,MDEyOklzc3VlQ29tbWVudDM4MTI2NzI0MA==,1217238,2018-04-13T21:39:47Z,2018-04-13T21:39:47Z,MEMBER,"> because selecting and assigning are discussed together. I think that should be fixed too.
Agreed, it is confusingly worded. I missed that when I reread it earlier.
If you're interested in tackling any of these issues, pull requests would be gratefully accepted! See here for guidelines:
http://xarray.pydata.org/en/stable/contributing.html#contributing-to-the-documentation","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,314239017
https://github.com/pydata/xarray/issues/2055#issuecomment-381254511,https://api.github.com/repos/pydata/xarray/issues/2055,381254511,MDEyOklzc3VlQ29tbWVudDM4MTI1NDUxMQ==,8453445,2018-04-13T20:38:09Z,2018-04-13T20:38:09Z,CONTRIBUTOR,"Regarding B)
I think that the current text can lead to confusion:
> Select or assign values by integer location (like numpy): x[:10] or by label (like pandas): x.loc['2014-01-01'] or x.sel(time='2014-01-01').
because selecting and assigning are discussed together. I think that should be fixed too.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,314239017
https://github.com/pydata/xarray/issues/2055#issuecomment-381252806,https://api.github.com/repos/pydata/xarray/issues/2055,381252806,MDEyOklzc3VlQ29tbWVudDM4MTI1MjgwNg==,1217238,2018-04-13T20:30:43Z,2018-04-13T20:30:43Z,MEMBER,"> A) I am not sure if it is possible, but maybe add a proper error to such thing - try to assign values when using any of the indexing methods - would be great.
Yes, totally agreed that this would be ideal, but unfortunately I don't think this is possible. Pandas attempted something with its SettingWithCopy warnings, but in most cases I think those just add noise and warm about something that isn't actually a problem.
> B) if A is not possible, maybe in the DataArray page you should repeat the Warning.
I don't know if it makes sense on the overview page for DataArray, but we should definitely repeat it on the doc page for `DataArray.sel`:
http://xarray.pydata.org/en/stable/generated/xarray.DataArray.sel.html
> C) you should add to the text of the Warning to use vectorized indexing, so people know how to fix the issue.
Yes, agreed!
D) Also for the vectorized indexing page, an example using .sel could help. For example, something like the following, which I think it should work (using your same dataArray within the vectorized indexing help)
Yes, I think we should add an example of using vectorized indexing for assignment.
We already have some examples of using it with `.sel()` further down the page, but I agree that label-based indexing should probably be more strongly emphasized: http://xarray.pydata.org/en/stable/indexing.html#more-advanced-indexing","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,314239017