-
Notifications
You must be signed in to change notification settings - Fork 50
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
Specifying a sort order when returning unique values #40
Comments
Most relevant comment from gh-25: @agarwal-ashish or @edloper do you have an opinion on this one? |
Unless we believe sorted order is almost always desired, it will be better to not enforce sorting and leave the API simpler. We could expect frameworks to perform operator fusion if this becomes a common performance bottleneck. |
I don't think it is. Just wanting to know the number of unique values for example is common enough that pandas offers a separate So then to write portable code, users should explicitly write So the right resolution then is probably:
In practice this is probably not so relevant. NumPy sorts anyway, and most other libraries have the ability (at least in principle) to do operator fusion. |
Sorting is also not well defined for complex dtypes (potentially for other advanced dtypes as well if those were ever added). See #102 (comment). I'm not clear what the final resolution of that is, but it sounds like the |
As discussed #25 (comment), we need to resolve if, and how, we should specify a sort order when returning unique values.
A corollary issue is, if we support an optional keyword to return sorted unique values, whether we should also support specifying the sort direction (ascending vs descending).
We could limit sorting to ascending order, but that this may be considered an arbitrary restriction may lend support for the argument of not returning ascending/descending sorted output at all. Instead, punting sorting to userland, where sort order can be specified via
sort()
. However, as discussed in the OP, combining unique/sort may allow implementation perf optimizations which cannot be replicated when performed as two separate steps.The text was updated successfully, but these errors were encountered: