-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Deprecate passing args as positional in sort_values #41505
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
Merged
jreback
merged 10 commits into
pandas-dev:master
from
MarcoGorelli:deprecate-nonkeyword-args-sort_values
May 26, 2021
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2a0270e
deprecate passing args as positional in sort_values
MarcoGorelli 92e0608
Merge remote-tracking branch 'upstream/master' into deprecate-nonkeyw…
MarcoGorelli fee3211
fixup post merge
MarcoGorelli c853346
Merge remote-tracking branch 'upstream/master' into deprecate-nonkeyw…
MarcoGorelli 2519540
Merge remote-tracking branch 'upstream/master' into deprecate-nonkeyw…
MarcoGorelli d741d8e
Merge branch 'master' into deprecate-nonkeyword-args-sort_values
jreback c1f9797
Merge branch 'master' into deprecate-nonkeyword-args-sort_values
jreback 84b2dab
Merge branch 'master' into deprecate-nonkeyword-args-sort_values
simonjayhawkins c37fb8a
Merge branch 'master' into deprecate-nonkeyword-args-sort_values
jreback a8f67c4
Merge branch 'master' into deprecate-nonkeyword-args-sort_values
MarcoGorelli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -647,6 +647,7 @@ Deprecations | |||||
- Deprecated setting :attr:`Categorical._codes`, create a new :class:`Categorical` with the desired codes instead (:issue:`40606`) | ||||||
- Deprecated behavior of :meth:`DatetimeIndex.union` with mixed timezones; in a future version both will be cast to UTC instead of object dtype (:issue:`39328`) | ||||||
- Deprecated using ``usecols`` with out of bounds indices for ``read_csv`` with ``engine="c"`` (:issue:`25623`) | ||||||
- Deprecated passing arguments as positional (except for ``by``) in :meth:`DataFrame.sort_values` and :meth:`Series.sort_values` (:issue:`41485`) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
.. --------------------------------------------------------------------------- | ||||||
|
||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -856,3 +856,13 @@ def test_sort_column_level_and_index_label( | |
tm.assert_frame_equal(result, expected) | ||
else: | ||
tm.assert_frame_equal(result, expected) | ||
|
||
def test_sort_values_pos_args_deprecation(self): | ||
# https://github.com/pandas-dev/pandas/issues/41485 | ||
df = DataFrame({"a": [1, 2, 3]}) | ||
msg = ( | ||
r"Starting with Pandas version 2\.0 all arguments of sort_values except " | ||
r"for the arguments 'self' and 'by' will be keyword-only" | ||
) | ||
with tm.assert_produces_warning(FutureWarning, match=msg): | ||
df.sort_values("a", 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as in other PRs regarding asserting the result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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 change won't solve the
error: Signature of "sort_values" incompatible with supertype "NDFrame" [override]
. maybe we could also giveby
a default value (the dataframe columns). The 'by' keyword could still be passed positionally if it has a default value.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.
we could also perhaps deprecate the axis keyword on Series at the same time to clean this up further.
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 don't understand, wouldn't this be incompatible with the supertype?
Sure, could that - that could be done directly in 1.3 without a prior warning, right? As current behaviour would be preserved
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 might be a good idea, but I would personally leave that for a separate PR (as it seems an independent new feature)