Skip to content

BUG: BooleanArray.any with all False values and skipna=False is buggy #33253

@jorisvandenbossche

Description

@jorisvandenbossche

From a report on my blog, this seems buggy:

In [10]: a = pd.array([False, False], dtype="boolean")  

In [11]: a  
Out[11]: 
<BooleanArray>
[False, False]
Length: 2, dtype: boolean

In [12]: a.any() 
Out[12]: False

In [13]: a.any(skipna=False)   
Out[13]: <NA>

I don't think there is a reason to return NA if there are no NAs in the array? (even with skipna=False)

We probably need to do a check for the presence of any NA here in the else clause:

if skipna:
return result
else:
if result or len(self) == 0:
return result
else:
return self.dtype.na_value

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNA - MaskedArraysRelated to pd.NA and nullable extension arrays

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions