-
-
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
Allow callables to .drop_vars
#8511
Conversation
This can be used as a nice more general alternative to `.drop_indexes` or `.reset_coords(drop=True)`
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
xarray/core/dataset.py
Outdated
@@ -5723,16 +5723,17 @@ def _assert_all_in_dataset( | |||
|
|||
def drop_vars( | |||
self, | |||
names: Hashable | Iterable[Hashable], | |||
names: Hashable | Iterable[Hashable] | Callable, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
names: Hashable | Iterable[Hashable] | Callable, | |
names: Hashable | Iterable[Hashable] | Callable[[Self], Hashable | Iterable[Hashable]], |
You could try this :)
And not to mention the old str | Iterable[Hashable]
story. But the code below seems fine with the current definition, so we can leave it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I also did some str | Iterable[Hashable]
tithing
for more information, see https://pre-commit.ci
This can be used as a nice more general alternative to
.drop_indexes
or.reset_coords(drop=True)