Skip to content

Commit d9fcad7

Browse files
committed
BUG: Make Series flex methods (truediv, floordiv, etc.) raise NotImplementedError for bool dtypes
This change ensures that flex methods like .truediv(), .rtruediv(), .floordiv(), .rfloordiv(), .pow(), .rpow() raise NotImplementedError for boolean dtypes, consistent with their dunder method counterparts (__truediv__, etc.). Previously, pd.Series([True]).truediv([True]) would return a float result, while pd.Series([True]) / [True] would raise NotImplementedError. This fixes the inconsistency by routing _binop through ops.arithmetic_op which includes the bool dtype check. Closes #63250
1 parent 944c527 commit d9fcad7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pandas/core/series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6718,7 +6718,7 @@ def _binop(self, other: Series, func, level=None, fill_value=None) -> Series:
67186718
this_vals, other_vals = ops.fill_binop(this._values, other._values, fill_value)
67196719

67206720
with np.errstate(all="ignore"):
6721-
result = func(this_vals, other_vals)
6721+
result = ops.arithmetic_op(this_vals, other_vals, func)
67226722

67236723
name = ops.get_op_result_name(self, other)
67246724

0 commit comments

Comments
 (0)