Skip to content

Commit 93d4461

Browse files
committed
BUG: fixed GH #56
1 parent 6b959f7 commit 93d4461

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pandas/core/series.py

+12
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ def _arith_method(op, name):
3535
'__sub__' : '__rsub__',
3636
'__div__' : '__rdiv__',
3737
'__mul__' : '__rmul__',
38+
'__radd__' : '__add__',
39+
'__rsub__' : '__sub__',
40+
'__rdiv__' : '__div__',
41+
'__rmul__' : '__mul__',
3842
}
3943
def wrapper(self, other):
4044
from pandas.core.frame import DataFrame
@@ -445,6 +449,14 @@ def copy(self):
445449
__div__ = _arith_method(operator.div, '__div__')
446450
__truediv__ = _arith_method(operator.truediv, '__truediv__')
447451
__pow__ = _arith_method(operator.pow, '__pow__')
452+
__truediv__ = _arith_method(operator.truediv, '__truediv__')
453+
454+
__radd__ = _arith_method(operator.add, '__add__')
455+
__rmul__ = _arith_method(operator.mul, '__mul__')
456+
__rsub__ = _arith_method(lambda x, y: y - x, '__sub__')
457+
__rdiv__ = _arith_method(lambda x, y: y / x, '__div__')
458+
__rtruediv__ = _arith_method(lambda x, y: y / x, '__truediv__')
459+
__rpow__ = _arith_method(lambda x, y: y ** x, '__pow__')
448460

449461
# Inplace operators
450462
__iadd__ = __add__

pandas/tests/test_series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ def test_operators_reverse_object(self):
461461
def _check_op(arr, op):
462462
result = op(1., arr)
463463
expected = op(1., arr.astype(float))
464-
assert_series_equal(result, expected)
464+
assert_series_equal(result.astype(float), expected)
465465

466466
_check_op(arr, operator.add)
467467
_check_op(arr, operator.sub)

0 commit comments

Comments
 (0)