Skip to content

Commit 6d212c7

Browse files
committed
Handle Series case correctly
Added comments to remind of Series case
1 parent 1a23578 commit 6d212c7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pandas/core/computation/expressions.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,15 @@ def _can_use_numexpr(op, op_str, a, b, dtype_check):
8080
# check for dtype compatibility
8181
dtypes = set()
8282
for o in [a, b]:
83-
if hasattr(o, "dtypes") and o.ndim > 1:
84-
s = o.dtypes.value_counts()
85-
if len(s) > 1:
86-
return False
87-
dtypes |= set(s.index.astype(str))
83+
if hasattr(o, "dtypes"):
84+
# Series implements dtypes, check for dimension count
85+
if o.ndim > 1:
86+
s = o.dtypes.value_counts()
87+
if len(s) > 1:
88+
return False
89+
dtypes |= set(s.index.astype(str))
90+
else:
91+
dtypes |= {o.dtypes.name}
8892
elif isinstance(o, np.ndarray):
8993
dtypes |= {o.dtype.name}
9094

0 commit comments

Comments
 (0)