Skip to content

API/BUG: Behaviour of NA in BooleanArray pow operation #34686

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

Open
jorisvandenbossche opened this issue Jun 10, 2020 · 1 comment
Open

API/BUG: Behaviour of NA in BooleanArray pow operation #34686

jorisvandenbossche opened this issue Jun 10, 2020 · 1 comment
Labels
API - Consistency Internal Consistency of API/Behavior Bug NA - MaskedArrays Related to pd.NA and nullable extension arrays Numeric Operations Arithmetic, Comparison, and Logical operations

Comments

@jorisvandenbossche
Copy link
Member

For IntegerArray, we have some special-case behaviour for NAs in pow operation. For example, 1 ** NA == 1 and not NA as normal NA-propagation would be.

For BooleanArray, we don't have that, but maybe we should do the same? So that the boolean power of boolean-cast-to-int8 power operations for the same?

Right now this is different:

>>> a = pd.array([True] * 3 + [False] * 3 + [None] * 3, dtype="boolean")
>>> b = pd.array([True, False, None] * 3, dtype="boolean")  
>>> a 
<BooleanArray>
[True, True, True, False, False, False, <NA>, <NA>, <NA>]
Length: 9, dtype: boolean
>>> b
<BooleanArray>
[True, False, <NA>, True, False, <NA>, True, False, <NA>]
Length: 9, dtype: boolean

>>> a ** b
<IntegerArray>
[1, 1, <NA>, 0, 1, <NA>, <NA>, <NA>, <NA>]
Length: 9, dtype: Int8

>>> a.astype("Int8") ** b.astype("Int8") 
<IntegerArray>
[1, 1, 1, 0, 1, <NA>, <NA>, 1, <NA>]
Length: 9, dtype: Int8
@jorisvandenbossche jorisvandenbossche added API - Consistency Internal Consistency of API/Behavior NA - MaskedArrays Related to pd.NA and nullable extension arrays labels Jun 10, 2020
@mroeschke mroeschke added Bug Numeric Operations Arithmetic, Comparison, and Logical operations labels Aug 8, 2021
@jbrockmendel
Copy link
Member

I'd be fine with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API - Consistency Internal Consistency of API/Behavior Bug NA - MaskedArrays Related to pd.NA and nullable extension arrays Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

No branches or pull requests

3 participants