-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Series[int].__setitem__(mask, td64_or_dt64) incorrect casting #39619
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
Conversation
jbrockmendel
commented
Feb 5, 2021
•
edited
Loading
edited
- closes #xxxx
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
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.
lgtm a possible followup
# https://github.com/numpy/numpy/issues/12550 | ||
# timedelta64 will incorrectly cast to int | ||
converted = [converted] * mask.sum() | ||
values[mask] = converted | ||
if not is_list_like(converted): |
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.
this pattern is pretty common, maybe a helper function?
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.
yah one more PR coming up that uses this pattern yet again; i think its going to end up in array_algos.putmask,
# expressions.where will cast np.timedelta64 to int | ||
result = self.values.copy() | ||
result[~cond] = [other] * (~cond).sum() | ||
dtype, _ = infer_dtype_from(other, pandas_dtype=True) |
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.
e.g here as well