Skip to content

BUG: Assigning boolean series with boolean indexer #61743

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

Merged

Conversation

yuanx749
Copy link
Contributor

Supersedes #60127

@yuanx749 yuanx749 changed the title Bug: Assigning boolean series with boolean indexer BUG: Assigning boolean series with boolean indexer Jun 29, 2025
@simonjayhawkins simonjayhawkins added Bug Indexing Related to indexing on series/frames, not to indexes themselves PDEP6-related related to PDEP6 (not upcasting during setitem-like Series operations) labels Jun 30, 2025
@@ -1926,7 +1926,12 @@ def np_can_hold_element(dtype: np.dtype, element: Any) -> Any:
# i.e. there are pd.NA elements
raise LossySetitemError
return element
# GH 57338 check boolean array set as object type
if tipo.kind == "O" and isinstance(element, np.ndarray):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test where element has a np.nan value too?

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 added in test_can_hold_element.py.

@yuanx749 yuanx749 force-pushed the bug_boolean_series_with_logical_indexer branch from e8e097b to c4f32d7 Compare June 30, 2025 18:01
@mroeschke mroeschke added this to the 3.0 milestone Jul 1, 2025
@mroeschke mroeschke merged commit 1c8614d into pandas-dev:main Jul 1, 2025
41 of 44 checks passed
@mroeschke
Copy link
Member

Thanks @yuanx749

@yuanx749 yuanx749 deleted the bug_boolean_series_with_logical_indexer branch July 1, 2025 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves PDEP6-related related to PDEP6 (not upcasting during setitem-like Series operations)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Incompatible dype warning when assigning boolean series with logical indexer
4 participants