Skip to content
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

Merged
merged 6 commits into from
Dec 3, 2023
Merged

Conversation

max-sixty
Copy link
Collaborator

This can be used as a nice more general alternative to .drop_indexes or .reset_coords(drop=True)

max-sixty and others added 2 commits December 2, 2023 11:39
This can be used as a nice more general alternative to `.drop_indexes` or `.reset_coords(drop=True)`
Copy link
Collaborator

@headtr1ck headtr1ck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@@ -5723,16 +5723,17 @@ def _assert_all_in_dataset(

def drop_vars(
self,
names: Hashable | Iterable[Hashable],
names: Hashable | Iterable[Hashable] | Callable,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Collaborator Author

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

@headtr1ck headtr1ck added the plan to merge Final call for comments label Dec 3, 2023
@max-sixty max-sixty merged commit 62a4d0f into pydata:main Dec 3, 2023
32 checks passed
@max-sixty max-sixty deleted the drop-callable branch December 3, 2023 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plan to merge Final call for comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants