We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1aba9a2 commit 5b20b59Copy full SHA for 5b20b59
pandas/core/arrays/datetimelike.py
@@ -1498,12 +1498,14 @@ def __rsub__(self, other):
1498
from pandas.core.arrays import DatetimeArray
1499
1500
datetime_result = self - other
1501
- if isinstance(datetime_result, DatetimeArray):
1502
- raise TypeError(
1503
- "TypeError: unsupported operand type(s) for -: "
1504
- f"'{type(self).__name__}' and '{type(other).__name__}'"
1505
- )
1506
- return -(datetime_result)
+ try:
+ return -(datetime_result)
+ except TypeError as e:
+ if isinstance(datetime_result, DatetimeArray):
+ raise TypeError(
+ "Unsupported operand type(s) for -: "
1507
+ f"'{type(self).__name__}' and '{type(other).__name__}'"
1508
+ ) from e
1509
1510
def __iadd__(self, other) -> Self:
1511
result = self + other
0 commit comments