-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fix series comparison operators when dealing with zero rank numpy arrays #13307
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
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 |
---|---|---|
|
@@ -754,7 +754,9 @@ def wrapper(self, other, axis=None): | |
elif isinstance(other, pd.DataFrame): # pragma: no cover | ||
return NotImplemented | ||
elif isinstance(other, (np.ndarray, pd.Index)): | ||
if len(self) != len(other): | ||
# do not check length of zerorank array | ||
if not lib.isscalar(lib.item_from_zerodim(other)) and \ | ||
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. Nitpick: I think it's "zero rank" instead of "zerorank" as you wrote in the |
||
len(self) != len(other): | ||
raise ValueError('Lengths must match to compare') | ||
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. I've been nitpicked on this before, but @jreback is there a preference for backslash or parentheses in multi-line conditionals? 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. either one are fine really. I guess in this case parens might be nicer. I'll fix on the merge |
||
return self._constructor(na_op(self.values, np.asarray(other)), | ||
index=self.index).__finalize__(self) | ||
|
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.
Ha, ha! Good catch, as that was one of my own changes 😄