-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
API DesignIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvesNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further action
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?
Metadata
Metadata
Assignees
Labels
API DesignIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvesNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further action