Skip to content

Mismatch in Series/DataFrame boolean ops behavior #22724

Closed
@jbrockmendel

Description

@jbrockmendel

Based on test_bool_ops_df_compat from tests.series.test_operators:

s1 = pd.Series([True, False, np.nan, True], dtype=object)
s2 = pd.Series([True, True, False, np.nan], dtype=object)

>>> s1 & s2
0     True
1    False
2    False
3    False
dtype: bool

>>> s1.to_frame() & s2.to_frame()
       0
0   True
1  False
2    NaN
3    NaN

The DataFrame behavior strikes me as More Correct. Is the mismatch intentional?

Metadata

Metadata

Assignees

No one assigned

    Labels

    API - ConsistencyInternal Consistency of API/BehaviorBugDataFrameDataFrame data structureMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolateNumeric 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