-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Series __setitem__ gives wrong result with bool indexer #30580
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
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 |
---|---|---|
|
@@ -944,15 +944,14 @@ def putmask(self, mask, new, align=True, inplace=False, axis=0, transpose=False) | |
and np.any(mask[mask]) | ||
and getattr(new, "ndim", 1) == 1 | ||
): | ||
|
||
if not ( | ||
mask.shape[-1] == len(new) | ||
or mask[mask].shape[-1] == len(new) | ||
or len(new) == 1 | ||
): | ||
if mask[mask].shape[-1] == len(new): # GH 30567 | ||
np.place(new_values, mask, new) | ||
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 had to look up what np.place was. is there a more common idiom we can use here? 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 can't find any close alternative from numpy. I think |
||
elif mask.shape[-1] == len(new) or len(new) == 1: | ||
np.putmask(new_values, mask, new) | ||
else: | ||
raise ValueError("cannot assign mismatch length to masked array") | ||
|
||
np.putmask(new_values, mask, new) | ||
else: | ||
np.putmask(new_values, mask, new) | ||
|
||
# maybe upcast me | ||
elif mask.any(): | ||
|
Uh oh!
There was an error while loading. Please reload this page.