[BUG/pandas-compat]: Handling of type promotion and division/mod by zero for boolean columns #12162
Labels
0 - Backlog
In queue waiting for assignment
bug
Something isn't working
Python
Affects Python cuDF API.
Milestone
After #12074, most type promotions between columns of mixed types (and non-mixed types) match pandas. The exception is columns with boolean dtypes.
Pandas have taken the decision to disallow division and exponentiation on boolean types when both operands are booleans (https://github.com/pandas-dev/pandas/blob/d13c9e034ce8a1d738766c4b1cec80c76f5523be/pandas/core/ops/array_ops.py#L503).
Aside: I kind of disagree with this since this is all perfectly well defined (excepting the usual caveat of division by zero).
When only one of the operands is
bool
, the status quo depends on the dtype of the other operand:Pandas behaviour:
For
a % b
, witha == 1
,b == 0
for various dtypesFor
a / b
(ora // b
) witha == 1
,b = 0
For
a % b
, witha == 0
,b == 0
for various dtypesFor
a / b
(ora // b
) witha == 0
,b = 0
cuDF behaviour:
For
a % b
, witha == 1
,b == 0
for various dtypesFor
a // b
witha == 1
,b = 0
For
a / b
witha == 1
,b = 0
For
a % b
, witha == 0
,b == 0
for various dtypesFor
a // b
witha == 0
,b = 0
For
a / b
witha == 0
,b = 0
Footnotes
If the operands are different lengths, we get a ZeroDivisionError (see https://github.com/pandas-dev/pandas/issues/49699) ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12
The text was updated successfully, but these errors were encountered: