Skip to content

Commit 5d69a4d

Browse files
committed
BUG: Fix __truediv__ numexpr error
by passing truediv=True to evaluate for __truediv__ and truediv=False for __div__.
1 parent ae8b7ab commit 5d69a4d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pandas/core/frame.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ class DataConflictError(Exception):
190190
# Factory helper methods
191191

192192

193-
def _arith_method(op, name, str_rep = None, default_axis='columns', fill_zeros=None):
193+
def _arith_method(op, name, str_rep = None, default_axis='columns', fill_zeros=None, **eval_kwargs):
194194
def na_op(x, y):
195195
try:
196-
result = expressions.evaluate(op, str_rep, x, y, raise_on_error=True)
196+
result = expressions.evaluate(op, str_rep, x, y, raise_on_error=True, **eval_kwargs)
197197
result = com._fill_zeros(result,y,fill_zeros)
198198

199199
except TypeError:
@@ -853,7 +853,7 @@ def __contains__(self, key):
853853
__sub__ = _arith_method(operator.sub, '__sub__', '-', default_axis=None)
854854
__mul__ = _arith_method(operator.mul, '__mul__', '*', default_axis=None)
855855
__truediv__ = _arith_method(operator.truediv, '__truediv__', '/',
856-
default_axis=None, fill_zeros=np.inf)
856+
default_axis=None, fill_zeros=np.inf, truediv=True)
857857
__floordiv__ = _arith_method(operator.floordiv, '__floordiv__',
858858
default_axis=None, fill_zeros=np.inf)
859859
__pow__ = _arith_method(operator.pow, '__pow__', '**', default_axis=None)
@@ -879,7 +879,7 @@ def __contains__(self, key):
879879
# Python 2 division methods
880880
if not py3compat.PY3:
881881
__div__ = _arith_method(operator.div, '__div__', '/',
882-
default_axis=None, fill_zeros=np.inf)
882+
default_axis=None, fill_zeros=np.inf, truediv=False)
883883
__rdiv__ = _arith_method(lambda x, y: y / x, '__rdiv__',
884884
default_axis=None, fill_zeros=np.inf)
885885

0 commit comments

Comments
 (0)