Skip to content

API: bool(pd.NA) #38224

Open
Open
@jreback

Description

@jreback

xref #38102 (comment)

for np.nan we define bool(np.nan)

In [189]: 1 or np.nan                                                                                                                                                                     
Out[189]: 1

In [190]: np.nan or 1                                                                                                                                                                     
Out[190]: nan

however we don't do this for pd.NA

>>> pd.NA or 1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pandas/_libs/missing.pyx", line 360, in pandas._libs.missing.NAType.__bool__
    raise TypeError("boolean value of NA is ambiguous")
TypeError: boolean value of NA is ambiguous

I think this is pretty odd and not very useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolateNA - MaskedArraysRelated to pd.NA and nullable extension arraysPDEP missing valuesIssues that would be addressed by the Ice Cream Agreement from the Aug 2023 sprint

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions