-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Fix .loc/.iloc/.at/iat cast unexpectedly with object dtype #49306
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
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.
Pretty good start. @jbrockmendel any thoughts?
@@ -973,8 +973,8 @@ def setitem(self, indexer, value) -> Block: | |||
|
|||
# length checking | |||
check_setitem_lengths(indexer, value, values) | |||
|
|||
value = extract_array(value, extract_numpy=True) | |||
if self.dtype != _dtype_obj: |
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.
Do we even need the extract_array
call at all? I think the point of it is to explicitly convert a Series / Index to an object-dtype ndarray. If that's the case you are trying to avoid I don't think even need the condition here
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.
I think we need the extract_array
call, otherwise, some tests in the indexing
folder will not pass.
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.
Interesting - do you know what the failures are? Are they Index-related?
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.
definitely add a comment here pointing back to the PR/issue
might be np_can_hold_element assumes extract_array has been called, don't quote me on that.
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.
@xr-chen can you confirm what @jbrockmendel is saying? I'm not sure yet if this is worth doing as is or if we should try to solve the issue comprehensively
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.
@WillAyd I think he was right, he definitely knows extract_array
and np_can_hold_element
better than me. Do you have any plans on fixing it comprehensively?
Co-authored-by: William Ayd <william.ayd@icloud.com>
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen. |
update branch obj
Thanks for reopening, I have merged in the main branch. Any suggestions for this pull request? |
Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen. |
.loc
/.iloc
/.at
/iat
setitem coerces a pd.Series to np.ndarray with object dtype #48933 (Replace xxxx with the GitHub issue number)doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.