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
Add option to preserve input order on table joins #11619
Comments
Fair enough. As a workaround you can do something like this:
If this were implemented, my guess for the most natural ordering is:
Does sound reasonable? Maybe a new If you'd like to take a crack at this, have a look at astropy/astropy/table/operations.py Line 395 in 5f8866e
|
What is status of this issue? I just faced this problem and I would be really happy to see it implemented. In the meantime, I urge you to update the API documentation and specifically mention that the original order won't be preserved and the result will be sorted. |
@astrobatty Thanks for reviving this issue. I've started working on the implementation of the |
Actually, thinking more about this, I think we can do better than a boolean
I think a better solution would be to expose a |
@neutrinoceros - that sounds like a good solution. The one thing I often do is look for precedent in pandas. Although astropy is not even close to API compatible, it can reduce friction to be similar where possible. Pandas appears to have a single bool Your idea might be more clear and better in the end, but have a look at pandas and see what you think. |
Ok, will do ! I don't think it matters to much at this point as I think I'll implement the bulk of the feature the same way in both cases, it's really just about of how we expose it, so we can discuss the exact API in my future PR ! |
Description
joins sort the resulting table by the join key. This is not documented in the actual API documentation of join here:
https://docs.astropy.org/en/stable/api/astropy.table.join.html
and just mentioned in passing here:
https://docs.astropy.org/en/stable/table/operations.html#join
This is undesired in many circumstances. There should be an option to preserve the input order, at least for left/right joins.
Additional context
Example:
results in:
The text was updated successfully, but these errors were encountered: