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 e5b75f0 commit 2e041b9Copy full SHA for 2e041b9
pandas/core/arrays/datetimelike.py
@@ -18,6 +18,7 @@
18
import warnings
19
20
import numpy as np
21
+import pandas
22
23
from pandas._config import using_string_dtype
24
from pandas._config.config import get_option
@@ -1488,7 +1489,11 @@ def __rsub__(self, other):
1488
1489
return (-self) + other
1490
1491
# We get here with e.g. datetime objects
- return -(self - other)
1492
+ datetime_result = self - other
1493
+ if isinstance(datetime_result, pandas.core.arrays.datetimes.DatetimeArray):
1494
+ raise TypeError("TypeError: unsupported operand type(s) for -: "
1495
+ f"'{type(self).__name__}' and '{type(other).__name__}'")
1496
+ return -(datetime_result)
1497
1498
def __iadd__(self, other) -> Self:
1499
result = self + other
0 commit comments