Skip to content

BUG/DEPR: logical operation with bool and string #61995

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
merged 1 commit into from
Jul 29, 2025

Conversation

jbrockmendel
Copy link
Member

@jbrockmendel jbrockmendel added this to the 2.3.2 milestone Jul 29, 2025
@mroeschke mroeschke added Numeric Operations Arithmetic, Comparison, and Logical operations Strings String extension data type and string data labels Jul 29, 2025
@mroeschke mroeschke merged commit 36b8f20 into pandas-dev:main Jul 29, 2025
43 checks passed
@mroeschke
Copy link
Member

Thanks @jbrockmendel

Copy link

lumberbot-app bot commented Jul 29, 2025

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout 2.3.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 36b8f20e06d3a322890173e6f520ed108825ea02
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #61995: BUG/DEPR: logical operation with bool and string'
  1. Push to a named branch:
git push YOURFORK 2.3.x:auto-backport-of-pr-61995-on-2.3.x
  1. Create a PR against branch 2.3.x, I would have named this PR:

"Backport PR #61995 on branch 2.3.x (BUG/DEPR: logical operation with bool and string)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

f"'{op_name}' operations between boolean dtype and {self.dtype} are "
"deprecated and will raise in a future version. Explicitly "
"cast the strings to a boolean dtype before operating instead.",
FutureWarning,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
FutureWarning,
DeprecationWarning,

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Thanks for looking at this!

@@ -25,7 +25,7 @@ Bug fixes
- Fix :meth:`~DataFrame.to_json` with ``orient="table"`` to correctly use the
"string" type in the JSON Table Schema for :class:`StringDtype` columns
(:issue:`61889`)

- Boolean operations (``|``, ``&``, ``^``) with bool-dtype objects on the left and :class:`StringDtype` objects on the right now cast the string to bool, with a deprecation warning (:issue:`60234`)
Copy link
Member

Choose a reason for hiding this comment

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

Your PR might have fixed both, but I don't think this is specific to bool dtype being on the left and string on the right? Both orders of operation fails right now?

Copy link
Member Author

Choose a reason for hiding this comment

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

The old behavior that we are trying to match (with object dtype) does depend specifically on the ndarray[bool] being on the left

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I was only testing with string dtype to check that both were failing. You're right that for object this only worked in that order. Ignore me!


msg = "operations between boolean dtype and"
with tm.assert_produces_warning(warn, match=msg):
result = left | right
Copy link
Member

Choose a reason for hiding this comment

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

Related to the other comment, would also test right | left

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Numeric Operations Arithmetic, Comparison, and Logical operations Still Needs Manual Backport Strings String extension data type and string data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG (string dtype): logical operation with bool and string failing
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy