Skip to content

API: boolean ops with float dtype #61881

@jbrockmendel

Description

@jbrockmendel
# from #60234 OP

ser1 = pd.Series([False, False])
ser2 = pd.Series([0.0, 0.1])

ser1 | ser2  # <- works by casting floats to bool
ser2 | ser1  # <- raises TypeError

# We also have special-casing for NaNs among floats

ser3 = pd.Series([np.nan, 1.0])

ser3 & ser3            # <- raises bc you can't do float & float
ser3[:-1] & ser3[:-1]  # has no non-NaN floats so we special-case

logical ops (&, |, ^) have inconsistent behavior. I think we should simplify this significantly and more closely resemble the numpy behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    API - ConsistencyInternal Consistency of API/BehaviorNeeds DiscussionRequires discussion from core team before further actionNullable by defaultIssues that would be addressed by moving to nullable-by-defaultNumeric OperationsArithmetic, Comparison, and Logical operations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions