-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TYP Series and DataFrame currently type-check as hashable #41283
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
Changes from 1 commit
89b56a4
34b3b0a
31593c3
c4c2ec1
3af9021
f913f04
d05deef
a05b86c
5cd29ed
0d09da2
78abb23
dee8b0b
3a8b333
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6152,26 +6152,26 @@ def f(vals) -> tuple[np.ndarray, int]: | |
return labels.astype("i8", copy=False), len(shape) | ||
|
||
if subset is None: | ||
subset = self.columns | ||
subset_iterable: Iterable = self.columns | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. another nit, preference for
to help distinguish cases were we need the variable type annotation (normally where the call to a function returns Any and would be redundant in the future when the return type of the called function is typed) vs a wider type used for a variable than the inferred type( i.e. the return type of the initial assignment to a variable) |
||
elif ( | ||
not np.iterable(subset) | ||
or isinstance(subset, str) | ||
or isinstance(subset, tuple) | ||
and subset in self.columns | ||
): | ||
subset = (subset,) | ||
|
||
# needed for mypy since can't narrow types using np.iterable | ||
subset = cast(Iterable, subset) | ||
subset_iterable = (subset,) | ||
else: | ||
# needed for mypy since can't narrow types using np.iterable | ||
subset_iterable = cast(Iterable, subset) | ||
|
||
# Verify all columns in subset exist in the queried dataframe | ||
# Otherwise, raise a KeyError, same as if you try to __getitem__ with a | ||
# key that doesn't exist. | ||
diff = Index(subset).difference(self.columns) | ||
diff = Index(subset_iterable).difference(self.columns) | ||
if not diff.empty: | ||
raise KeyError(diff) | ||
|
||
vals = (col.values for name, col in self.items() if name in subset) | ||
vals = (col.values for name, col in self.items() if name in subset_iterable) | ||
labels, shape = map(list, zip(*map(f, vals))) | ||
|
||
ids = get_group_index( | ||
|
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.
nit.