Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DISC] Index[object] ops #21315

Closed
jbrockmendel opened this issue Jun 4, 2018 · 1 comment
Closed

[DISC] Index[object] ops #21315

jbrockmendel opened this issue Jun 4, 2018 · 1 comment
Labels
API Design Indexing Related to indexing on series/frames, not to indexes themselves Needs Discussion Requires discussion from core team before further action

Comments

@jbrockmendel
Copy link
Member

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?

@gfyoung gfyoung added Indexing Related to indexing on series/frames, not to indexes themselves Needs Discussion Requires discussion from core team before further action API Design labels Jun 6, 2018
@jbrockmendel
Copy link
Member Author

Closing in favor of #19369

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Indexing Related to indexing on series/frames, not to indexes themselves Needs Discussion Requires discussion from core team before further action
Projects
None yet
Development

No branches or pull requests

2 participants