Skip to content

API/DEPR: disallow casting nan-float to bool #62687

@jbrockmendel

Description

@jbrockmendel

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

ser = pd.Series([np.nan]) >>> ser.astype(bool) 0 True

This is correct inasmuch as bool(np.nan) is True, but I think it's a bit surprising. Analogous to how we deprecated and later disallowed .astype("int64") when NaNs are present, should we deprecate allowing this for bool?

xref #43018

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions