-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Add arithmetic to categoricals? #8629
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
Comments
i believe the thinking was that Categoricals were primarily for strings. But for a numeric (sub-dtype) then certainly this is possible. can you update with an example of the usecase pls. |
Yeah, I'm actually not entirely sure this is a good idea, given that numbers can already be represented as efficiently in essentially the same space as the categorical codes. |
Actually going to close this, I was getting ahead of myself here. I'm struggling to think of an actual use case for this. |
hmm,maybe for a limited set(e.g. < 128) it would save some memory |
Categoricals represents "categories", so in "most" cases nothing with a defined difference (needed for '-' and '+') and no zero (so no '*' or '/'). Even if we have integers as a representation for the categories... If we really want to have some memory efficient whatever, we can, but then please make that a different class. |
@shoyer Just FYI: Schulz without 'tz', I just found this issues :-) |
I'm not entirely sure why (perhaps just the trouble of implementing it), but categoricals do not currently support arithmetic:
Similarly to string operations (#8627), arithmetic with scalars could very efficient transform categoricals into new categoricals.
In contrast, array + array operations should probably just return a normal array.
CC @JanSchultz @jreback
The text was updated successfully, but these errors were encountered: