-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update_attrs method #1281
Comments
I would like something like this as well! |
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
I like this idea, though I would call it I encourage you to get started on a pull request!
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 :). |
Thanks for the tip. I'll give it a shot. |
Thanks for the PR @hsharrison Do ppl think the cost of an extra method is worth the cleaner syntax? Would If python had a cleaner lambda... |
FWIW I've been doing
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. |
Right, yes. Then there's no reasonable solution without this addition, I think |
See the comment here for more information: pydata/xarray#1281 (comment)
See the comment here for more information: pydata/xarray#1281 (comment)
Updating attrs is an operation that consistently breaks up my method chaining. This should be easy to solve with something like
Thoughts?
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 text was updated successfully, but these errors were encountered: