-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
BUG: setting dt64 values into Series[int] incorrectly casting dt64->int #39266
Conversation
jbrockmendel
commented
Jan 19, 2021
•
edited
Loading
edited
- closes #xxxx
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
pandas/core/internals/blocks.py
Outdated
if is_list_like(value): | ||
value = list(value) | ||
else: | ||
value = [value] * len(values[indexer]) |
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.
maybe use np.full
?
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.
same as above re numpy#12550
pandas/core/internals/blocks.py
Outdated
# 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 comment
The reason will be displayed to describe this comment to others. Learn more.
np.asarray
?
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.
until numpy#12550 is fixed this is the only way i found to get this to work
pandas/core/internals/blocks.py
Outdated
@@ -991,6 +991,18 @@ def setitem(self, indexer, value): | |||
|
|||
# set | |||
else: | |||
if ( |
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
pandas/core/internals/blocks.py
Outdated
@@ -991,6 +991,18 @@ def setitem(self, indexer, value): | |||
|
|||
# set | |||
else: | |||
if ( |
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
ok, will update. BTW #38709, #39044, #39163 also touch this code, will need to get those merged/rejected in order to move forward on the refactor in #39302. (and a very gentle ping on #38992 since I want to write more tests) |
rebased + green |
lgtm. can you merge master and ping on green |
…g-setitem-dt64-int