Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More NA handling in binary ops with object Series #737

Closed
wesm opened this issue Feb 2, 2012 · 0 comments
Closed

More NA handling in binary ops with object Series #737

wesm opened this issue Feb 2, 2012 · 0 comments
Milestone

Comments

@wesm
Copy link
Member

wesm commented Feb 2, 2012

>>> 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/<ipython-input-21-9b098b74978c> in <module>()
----> 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/<ipython-input-19-64e88cc97e2c> in <module>()
----> 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 <lambda>(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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant