-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: setting dt64 values into Series[int] incorrectly casting dt64->int #39266
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 2 commits
8923cc8
1076052
2d358d4
38b5646
3598c07
fc5b66e
5672264
7a2e0e4
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 |
---|---|---|
|
@@ -991,6 +991,18 @@ def setitem(self, indexer, value): | |
|
||
# set | ||
else: | ||
if ( | ||
self.is_object | ||
and not is_ea_value | ||
and arr_value.dtype.kind in ["m", "M"] | ||
): | ||
# https://github.com/numpy/numpy/issues/12550 | ||
# numpy will incorrect cast to int if we're not careful | ||
if is_list_like(value): | ||
value = list(value) | ||
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.
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. until numpy#12550 is fixed this is the only way i found to get this to work |
||
else: | ||
value = [value] * len(values[indexer]) | ||
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. maybe use 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. same as above re numpy#12550 |
||
|
||
values[indexer] = value | ||
|
||
if transpose: | ||
|
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.
elif?
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.
no, we still want to fall through to L1006
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.
sure but i thin it is much more clear to use an elif and then simply repeat that line in the else
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.
updated + green