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/1281#issuecomment-282155745,https://api.github.com/repos/pydata/xarray/issues/1281,282155745,MDEyOklzc3VlQ29tbWVudDI4MjE1NTc0NQ==,5635139,2017-02-23T23:29:28Z,2017-02-23T23:29:28Z,MEMBER,"> A lambda solution is more difficult (maybe impossible?) because you need to update the attrs and return the original object to continue the pipe.
Right, yes. Then there's no reasonable solution without this addition, I think","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,209523348
https://github.com/pydata/xarray/issues/1281#issuecomment-282146064,https://api.github.com/repos/pydata/xarray/issues/1281,282146064,MDEyOklzc3VlQ29tbWVudDI4MjE0NjA2NA==,4441865,2017-02-23T22:43:10Z,2017-02-23T22:43:10Z,CONTRIBUTOR,"FWIW I've been doing
def update_attrs(obj, *args, **kwargs):
obj.attrs.update(*args, **kwargs)
return obj
ds.pipe(update_attrs, foo='bar')
which, yeah, is not too painful. But when I find myself using it every time I use xarray it makes me wish it was included.
A lambda solution is more difficult (maybe impossible?) because you need to update the attrs *and* return the original object to continue the pipe.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,209523348
https://github.com/pydata/xarray/issues/1281#issuecomment-282123529,https://api.github.com/repos/pydata/xarray/issues/1281,282123529,MDEyOklzc3VlQ29tbWVudDI4MjEyMzUyOQ==,5635139,2017-02-23T21:15:53Z,2017-02-23T21:15:53Z,MEMBER,"Thanks for the PR @hsharrison
Do ppl think the cost of an extra method is worth the cleaner syntax? Would `ds.pipe(lambda x: x.attrs.update(foo=bar')` suffice? It's easier to add methods than to remove them, though this approach does look nicer.
If python had a cleaner lambda...","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,209523348
https://github.com/pydata/xarray/issues/1281#issuecomment-281908185,https://api.github.com/repos/pydata/xarray/issues/1281,281908185,MDEyOklzc3VlQ29tbWVudDI4MTkwODE4NQ==,4441865,2017-02-23T06:36:18Z,2017-02-23T06:36:18Z,CONTRIBUTOR,Thanks for the tip. I'll give it a shot.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,209523348
https://github.com/pydata/xarray/issues/1281#issuecomment-281881318,https://api.github.com/repos/pydata/xarray/issues/1281,281881318,MDEyOklzc3VlQ29tbWVudDI4MTg4MTMxOA==,1217238,2017-02-23T03:15:18Z,2017-02-23T03:15:18Z,MEMBER,"> edit: I guess it should return a modified object rather than acting as an in-place operation...is copying appropriate here? How is this usually handled?
The standard thing to do would be to do a shallow copy of the original object (which copies everything except array data) and then update `attrs` inplace, e.g.,
```
def update_attrs(self, *args, **kwargs):
out = self.copy(deep=False)
out.attrs.update(*args, **kwargs)
return out
```
I like this idea, though I would call it `assign_attrs` rather than `update_coords`, to mirror `assign` and `assign_coords`.
I encourage you to get started on a pull request!
> Also, specifying default attrs for all data arrays of a dataset (like missing_data/ _FillValue/ ...) would be nice... Not sure if this is currently possible?
I don't think there's any way to do this currently without a loop. I would say we're open to proposals, which you should probably open another issue to discuss :).","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,209523348
https://github.com/pydata/xarray/issues/1281#issuecomment-281774695,https://api.github.com/repos/pydata/xarray/issues/1281,281774695,MDEyOklzc3VlQ29tbWVudDI4MTc3NDY5NQ==,13906519,2017-02-22T19:27:03Z,2017-02-22T19:27:03Z,NONE,"I would like something like this as well!
Also, specifying default attrs for all data arrays of a dataset (like missing_data/ _FillValue/ ...) would be nice... Not sure if this is currently possible? ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,209523348