Closed
Description
My understanding is that Index[object]
was originally written with strings in mind, which is why ops like __sub__
and __neg__
don't make sense. Since we've got more non-string cases (e.g. #21314), what if instead these were defined something like:
def __neg__(self):
return Index([-x for x in self])
def __sub__(self, other): # hand-wave appropriate handling for scalar vs vector other
return Index([x - other for x in self])
The string cases would still raise, but for things like Decimal and DateOffset we could get the "natural" behavior. Thoughts?