wesm/pandas — Issue #737: More NA handling in binary ops with object Series
Author: wesm
Created: 2012-02-02 17:35:27+00:00
State: open
Labels: Enhancement, prio-high

```
>>> y = [Decimal('1.3'), Decimal('2.3')]
>>> y2 = [datetime.date(2012,1,1), datetime.date(2012,1,2)]
>>> y3 = Series(y, index=y2)

In [21]: y3 + y3.shift(1)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/wesm/code/pandas/ in ()
----> 1 y3 + y3.shift(1)

/home/wesm/code/pandas/pandas/core/series.py in wrapper(self, other)
52 if self.index.equals(other.index):
53 name = _maybe_match_name(self, other)
---> 54 return Series(op(self.values, other.values), index=self.index,
55 name=name)
56

TypeError: unsupported operand type(s) for +: 'Decimal' and 'float'

In [17]: s = Series(['foo', 'bar', 'baz', np.nan])

In [18]: s
Out[18]:
0 foo
1 bar
2 baz
3 NaN

In [19]: 'prefix_' + s
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/wesm/code/pandas/ in ()
----> 1 'prefix_' + s

/home/wesm/code/pandas/pandas/core/series.py in wrapper(self, other)
65 else:
66 # scalars

---> 67 return Series(op(self.values, other), index=self.index,
68 name=self.name)
69 return wrapper

/home/wesm/code/pandas/pandas/core/series.py in _radd_compat(left, right)
73 # GH #353, NumPy 1.5.1 workaround

74 try:
---> 75 output = radd(left, right)
76 except TypeError:
77 cond = (_np_version_under1p6 and

/home/wesm/code/pandas/pandas/core/series.py in (x, y)
70
71 def _radd_compat(left, right):
---> 72 radd = lambda x, y: y + x
73 # GH #353, NumPy 1.5.1 workaround

74 try:

TypeError: cannot concatenate 'str' and 'float' objects
```