Skip to content

DateOffsets raise TypeError rather than NotImplemented on arithmetic #5033

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

Closed
jtratner opened this issue Sep 29, 2013 · 3 comments · Fixed by #5022
Closed

DateOffsets raise TypeError rather than NotImplemented on arithmetic #5033

jtratner opened this issue Sep 29, 2013 · 3 comments · Fixed by #5022
Labels
Frequency DateOffsets
Milestone

Comments

@jtratner
Copy link
Contributor

this blocks delegation to the __r*__ methods.

In [7]: %paste
        s = Series([Timestamp('20130101 9:01'), Timestamp('20130101 9:02')])
## -- End pasted text --

In [8]: s
Out[8]:
0   2013-01-01 09:01:00
1   2013-01-01 09:02:00
dtype: datetime64[ns]

In [9]: offsets.Second(5)
Out[9]: <5 * Seconds>

In [10]: offsets.Second(5) + s
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-48c2ebc28d0d> in <module>()
----> 1 offsets.Second(5) + s

../pandas/tseries/offsets.pyc in __add__(self, other)
   1178             else:
   1179                 return _delta_to_tick(self.delta + other.delta)
-> 1180         return self.apply(other)
   1181
   1182     def __eq__(self, other):

../pandas/tseries/offsets.pyc in apply(self, other)
   1222             return type(self)(self.n + other.n)
   1223         else:  # pragma: no cover
-> 1224             raise TypeError('Unhandled type: %s' % type(other))
   1225
   1226     _rule_base = 'undefined'

TypeError: Unhandled type: <class 'pandas.core.series.Series'>

In [11]: s + offsets.Second(5)
Out[11]:
0   2013-01-01 09:01:05
1   2013-01-01 09:02:05
dtype: datetime64[ns]
@cpcloud
Copy link
Member

cpcloud commented Sep 29, 2013

simple fix, no?

@jtratner
Copy link
Contributor Author

probably. I don't have time to do it right now.

@jtratner
Copy link
Contributor Author

Never mind figured it out :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frequency DateOffsets
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants