Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 examples for
issorted
docstrings. #2941Add examples for
issorted
docstrings. #2941Changes from 1 commit
863b70c
86ebca0
90ca4f1
9645de4
bfd3b5b
3e6e079
898c361
8bdd0de
3cef39e
087eadb
b8e44e6
f45e63c
f8db3fa
99d3bfe
fc834f0
35c8675
8e06298
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an important comment. Can you please add it also to
sort
andsort!
. Also can you make it more precise that "no column is specified" means "column selector selects no columns".@nalimilan - this rule is non-intuitive, but changing it would be breaking. Should we deprecate this behavior for 2.0 release (it would be a separate PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Chandu-4444 - if what I write is not clear please comment and I will give you examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get this and will do the same.
This, I didn't understand (And I'm really curious). Can you please elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sort
and related functions were developed in very early days of DataFrames.jl when there was no precise rules for the whole ecosystem. Therefore some inconsistencies slipped through.A proper definition of
sort
should be (I am skipping kwargs):however it is
and as a consequence if you pass any column selector that selects no columns the data frame is sorted lexicographically.
While technically it should happen if you select
All()
columns. If you select no columns a proper behavior should be that the data frame is not reordered (it is left as is as you have not requested on what the data frame should be sorted).We have two options:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get it now, thanks for that excellent explanation. Perhaps this column selector can be made a required argument (Like the one Python has in Pandas)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be even more breaking. By proposing the change to:
we are not breaking calls like
sort(df)
which are quite likely to exist in current user code.We try to limit breaking changes. Calls like
sort(df, [])
are quite unlikely, so we could deprecate them and change their behavior in 2.0.Let us wait for an opinion from @nalimilan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's indeed unfortunate. I'm not sure we should make a breaking change though given that it's not super likely to confuse people (if you call
sort
with no columns, it's most likely a mistake anyway and you'll get unexpected results), so I'd opt for a deprecation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK - let us then document that passing no columns is an undefined behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than repeating this here (which would have to be put in all sorting functions), how about putting
cols=All()
in the signature above? We could also change the actual implementation to make it clearer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I want to do. I will make these changes to this PR and then let @Chandu-4444 to sync the docs following your suggestions and writing that passing no columns leads to an undefined row order.