diff --git a/pandas/core/series.py b/pandas/core/series.py index 1ea8bbbaa0cfb..22eb33e0a95ed 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -6718,7 +6718,20 @@ def _binop(self, other: Series, func, level=None, fill_value=None) -> Series: this_vals, other_vals = ops.fill_binop(this._values, other._values, fill_value) with np.errstate(all="ignore"): - result = func(this_vals, other_vals) + # GH#63250: Use arithmetic_op for arithmetic operations to ensure + # consistent behavior with dunder methods (includes _bool_arith_check) + # But use direct func call for comparison operations (gt, lt, etc.) + if func in ( + operator.gt, + operator.ge, + operator.lt, + operator.le, + operator.eq, + operator.ne, + ): + result = func(this_vals, other_vals) + else: + result = ops.arithmetic_op(this_vals, other_vals, func) name = ops.get_op_result_name(self, other) diff --git a/pandas/tests/series/test_arithmetic.py b/pandas/tests/series/test_arithmetic.py index a77e55612e23d..94d78df665aaf 100644 --- a/pandas/tests/series/test_arithmetic.py +++ b/pandas/tests/series/test_arithmetic.py @@ -198,6 +198,20 @@ def test_flex_disallows_dataframe(self): with pytest.raises(TypeError, match=msg): ser.add(df, axis=0) + @pytest.mark.parametrize( + "opname", ["truediv", "rtruediv", "floordiv", "rfloordiv", "pow", "rpow"] + ) + def test_flex_method_bool_dtype_raises(self, opname): + # GH#63250 - flex methods should raise NotImplementedError for bool dtypes + # consistent with their dunder counterparts + ser = Series([True, False, True]) + other = Series([False, True, True]) + + op = getattr(Series, opname) + msg = f"operator '{opname.removeprefix('r')}' not implemented for bool dtypes" + with pytest.raises(NotImplementedError, match=msg): + op(ser, other) + class TestSeriesArithmetic: # Some of these may end up in tests/arithmetic, but are not yet sorted