Skip to content

Commit b5e7ade

Browse files
committed
BUG: Series.__radd__ needs to be order-specific with string series, GH #353
1 parent be8d385 commit b5e7ade

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

RELEASE.rst

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ pandas 0.5.1
9090
not in ascending order (GH #349)
9191
- Fix failure passing Int64Index to Index.union when both are monotonic
9292
- Fix error when passing SparseSeries to (dense) DataFrame constructor
93+
- Added missing bang at top of setup.py (GH #352)
9394

9495
Thanks
9596
------

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ def iteritems(self):
470470
__floordiv__ = _arith_method(operator.floordiv, '__floordiv__')
471471
__pow__ = _arith_method(operator.pow, '__pow__')
472472

473-
__radd__ = _arith_method(operator.add, '__add__')
473+
__radd__ = _arith_method(lambda x, y: y + x, '__add__')
474474
__rmul__ = _arith_method(operator.mul, '__mul__')
475475
__rsub__ = _arith_method(lambda x, y: y - x, '__sub__')
476476
__rtruediv__ = _arith_method(lambda x, y: y / x, '__truediv__')

pandas/tests/test_series.py

+8
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,8 @@ def test_operators_corner(self):
706706
self.assert_(np.array_equal(added[:-5], expected))
707707

708708
def test_operators_reverse_object(self):
709+
from pandas.util.testing import rands
710+
709711
# GH 56
710712
arr = Series(np.random.randn(10), index=np.arange(10),
711713
dtype=object)
@@ -721,6 +723,12 @@ def _check_op(arr, op):
721723
_check_op(arr, operator.truediv)
722724
_check_op(arr, operator.floordiv)
723725

726+
# GH 353
727+
vals = Series([rands(5) for _ in xrange(10)])
728+
result = 'foo_' + vals
729+
expected = vals.map(lambda x: 'foo_' + x)
730+
assert_series_equal(result, expected)
731+
724732
def test_operators_frame(self):
725733
# rpow does not work with DataFrame
726734
df = DataFrame({'A' : self.ts})

0 commit comments

Comments
 (0)