Skip to content

Commit a228d1e

Browse files
committed
BUG: check for dtype attr then check block types if no dtype attr
1 parent 304a52e commit a228d1e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pandas/computation/expressions.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,16 @@ def _where_numexpr(cond, a, b, raise_on_error=False):
154154
set_use_numexpr(True)
155155

156156

157-
def _bool_arith_check(op_str, a, b, not_allowed=('+', '*', '-', '/',
158-
'//', '**')):
159-
if op_str in not_allowed and a.dtype == bool and b.dtype == bool:
157+
def _has_bool_dtype(x):
158+
try:
159+
return x.dtype == bool
160+
except AttributeError:
161+
return 'bool' in x.blocks
162+
163+
164+
def _bool_arith_check(op_str, a, b, not_allowed=frozenset(('+', '*', '-', '/',
165+
'//', '**'))):
166+
if op_str in not_allowed and _has_bool_dtype(a) and _has_bool_dtype(b):
160167
raise NotImplementedError("operator %r not implemented for bool "
161168
"dtypes" % op_str)
162169

0 commit comments

Comments
 (0)