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/5048#issuecomment-1101516883,https://api.github.com/repos/pydata/xarray/issues/5048,1101516883,IC_kwDOAMm_X85Bp9BT,2448579,2022-04-18T15:52:30Z,2022-04-18T15:52:30Z,MEMBER,Closing in favour of #6377,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,834273555 https://github.com/pydata/xarray/issues/5048#issuecomment-804363539,https://api.github.com/repos/pydata/xarray/issues/5048,804363539,MDEyOklzc3VlQ29tbWVudDgwNDM2MzUzOQ==,1217238,2021-03-22T20:14:47Z,2021-03-22T20:14:47Z,MEMBER,"NumPy has ""select"" and ""choose"" for this, but I don't really love either of those APIs, either. Maybe `replace_in_data` or `update_data` would be appropriate names for a `DataArray` method that uses a dictionary as an argument? Then updating a coordinate would be solved with something like: e.g., ```python da['two'] = da['two'].replace_in_data({'dd': 'd'}) ```","{""total_count"": 3, ""+1"": 3, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,834273555 https://github.com/pydata/xarray/issues/5048#issuecomment-804297243,https://api.github.com/repos/pydata/xarray/issues/5048,804297243,MDEyOklzc3VlQ29tbWVudDgwNDI5NzI0Mw==,9399446,2021-03-22T18:32:55Z,2021-03-22T18:32:55Z,NONE,"@andersy005 's method definitely works, and I can iterate to do it for multiple names, so I've already gone away happy. A dedicated method would be nice though :). ""rename"" is understandably overloaded ... would something like ""update_coords"" be workable? It sort of matches the existing ""assign_coords"". ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,834273555 https://github.com/pydata/xarray/issues/5048#issuecomment-801627246,https://api.github.com/repos/pydata/xarray/issues/5048,801627246,MDEyOklzc3VlQ29tbWVudDgwMTYyNzI0Ng==,5635139,2021-03-18T05:02:10Z,2021-03-18T05:02:10Z,MEMBER,"Agree with @andersy005 's suggestion (and it takes a `lambda` fwiw) Though I also find myself reaching for a method like pandas' `rename` occasionally. Aside from the `rename` name, which I think is not good, what do others think about a method that takes a mapping and replaces values?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,834273555 https://github.com/pydata/xarray/issues/5048#issuecomment-801530191,https://api.github.com/repos/pydata/xarray/issues/5048,801530191,MDEyOklzc3VlQ29tbWVudDgwMTUzMDE5MQ==,9399446,2021-03-18T00:35:13Z,2021-03-18T00:50:12Z,NONE,"I have not ... that does work! Do you have a nice way to do that for a whole set? I only used one here, but I'm typically renaming something like 5-8 at a time, so ""rdict"" would be much bigger.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,834273555 https://github.com/pydata/xarray/issues/5048#issuecomment-801528450,https://api.github.com/repos/pydata/xarray/issues/5048,801528450,MDEyOklzc3VlQ29tbWVudDgwMTUyODQ1MA==,13301940,2021-03-18T00:30:24Z,2021-03-18T00:30:24Z,MEMBER,"@Jeitan, have you looked into [`where()`](https://xarray.pydata.org/en/stable/generated/xarray.DataArray.where.html) yet? ```python In [16]: da['two'] = da.two.where(da.two != 'dd', 'd') In [17]: da Out[17]: array([[-0.01774725, 0.42453644, -0.80758257, 0.18659729, -1.14712204], [ 2.06813654, 1.32605605, -1.49284031, 0.5929485 , -2.29315181], [ 0.30243348, 0.05863335, 2.09869485, 1.79054292, -0.99844954]]) Coordinates: * one (one) int64 1 2 3 * two (two)