issue_comments: 385000519
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/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 dataarrayds['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 maskmask = (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 , 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 |