-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
fixes #26622: pd.MultiIndex.isin should fail when input args are too short #26623
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 all commits
7c5db77
8a5fa2c
fb7a278
b932e65
12d03a6
84ccf0b
30901e8
16cb612
93f2038
47fbed2
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 |
---|---|---|
|
@@ -3175,6 +3175,14 @@ def _wrap_joined_index(self, joined, other): | |
@Appender(Index.isin.__doc__) | ||
def isin(self, values, level=None): | ||
if level is None: | ||
# validate value length | ||
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. hmm, we already do this sort of validation in I am not opposed to the check, but it seems that maybe the semantics of handling this are not exactly right, meaning what you passed in your tests is actually valid. |
||
nlvl = len(self.levels) | ||
for val in values: | ||
if len(val) != nlvl: | ||
raise ValueError('Length of each element in values must ' | ||
'match number of levels in MultiIndex. ' | ||
'len({}) != {}'.format(val, nlvl)) | ||
|
||
simonjayhawkins marked this conversation as resolved.
Show resolved
Hide resolved
|
||
values = MultiIndex.from_tuples(values, | ||
names=self.names).values | ||
return algos.isin(self.values, values) | ||
|
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.
Can you move this to 1.0.0?