Skip to content

DEPR: Series logical ops with different index coercing to bool #52839

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 5 commits into from
May 1, 2023

Conversation

mroeschke
Copy link
Member

@mroeschke mroeschke commented Apr 21, 2023

@mroeschke mroeschke added Dtype Conversions Unexpected or buggy dtype conversions Numeric Operations Arithmetic, Comparison, and Logical operations labels Apr 21, 2023
@jbrockmendel
Copy link
Member

jbrockmendel commented Apr 21, 2023

I for sure prefer this behavior, but its definitely intentional so not sure we can call it a bugfix.

The approach i've been kicking around (with little success) for non-aligned cases is to do a .align(join="inner") before operating, kind of like how we do _arith_method_with_reindex

Update: also could just deprecate automatic alignment for logical ops

@mroeschke mroeschke changed the title BUG: Series logical ops with different index coercing to bool DEPR: Series logical ops with different index coercing to bool Apr 21, 2023
@mroeschke
Copy link
Member Author

Fair point. I went ahead and deprecated this behavior instead

"to maintain the prior behavior.",
FutureWarning,
stacklevel=find_stack_level(),
)
Copy link
Member

Choose a reason for hiding this comment

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

FWIW i think we should deprecate this casting in all cases

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed, I just wanted to issue to warning though were the result type would change i.e. is a user is doing logical ops on booleans they should already get a boolean result hence no need to warn

Copy link
Member

Choose a reason for hiding this comment

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

so do we need to do a second deprecation to handle more cases or when this deprecation is enforced will we be able to remove the entire align_asobject block?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we'll be able to remove the entire align_asobject block once this is enforced. The added if statement is just warning in the cases where the result type will change in the future

@mroeschke mroeschke added this to the 2.1 milestone Apr 24, 2023
@mroeschke mroeschke added the Deprecate Functionality to remove in pandas label Apr 24, 2023
@mroeschke
Copy link
Member Author

Going to merge, but can address any followups

@mroeschke mroeschke merged commit 4ea0ce1 into pandas-dev:main May 1, 2023
@mroeschke mroeschke deleted the bug/series/logical_ops branch May 1, 2023 18:02
topper-123 pushed a commit to topper-123/pandas that referenced this pull request May 7, 2023
…s-dev#52839)

* BUG: Series logical ops with different index coercing to bool

* Turn into a deprecation

* Fix condition

* Make futurewarning more specific
Rylie-W pushed a commit to Rylie-W/pandas that referenced this pull request May 19, 2023
…s-dev#52839)

* BUG: Series logical ops with different index coercing to bool

* Turn into a deprecation

* Fix condition

* Make futurewarning more specific
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
…s-dev#52839)

* BUG: Series logical ops with different index coercing to bool

* Turn into a deprecation

* Fix condition

* Make futurewarning more specific
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Dtype Conversions Unexpected or buggy dtype conversions Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: inconsistent Series/DataFrame behavior in bitwise ops BUG: Results of series bitwise ufunc operations are being casted to bool in pandas-2.0
2 participants