Skip to content

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

Closed
wants to merge 10 commits into from

Conversation

xr-chen
Copy link
Contributor

@xr-chen xr-chen commented Oct 25, 2022

Copy link
Member

@WillAyd WillAyd left a 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:
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

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

Copy link
Contributor Author

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?

@WillAyd WillAyd added the Indexing Related to indexing on series/frames, not to indexes themselves label Oct 25, 2022
xr-chen and others added 2 commits October 25, 2022 14:01
Co-authored-by: William Ayd <william.ayd@icloud.com>
@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2022

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.

@github-actions github-actions bot added the Stale label Dec 1, 2022
@mroeschke
Copy link
Member

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.

@xr-chen
Copy link
Contributor Author

xr-chen commented Jan 11, 2023

Thanks for reopening, I have merged in the main branch. Any suggestions for this pull request?

@mroeschke
Copy link
Member

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.

@mroeschke mroeschke closed this Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: .loc/.iloc/.at/iat setitem coerces a pd.Series to np.ndarray with object dtype
6 participants