Skip to content

DateOffsets raise TypeError rather than NotImplemented on arithmetic #5033

Closed
@jtratner

Description

@jtratner

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions