-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Deprecate passing default args as positional in DataFrame.set_index #41495
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 6 commits into
pandas-dev:master
from
MarcoGorelli:deprecate-nonkeyword-args-replace
May 26, 2021
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f90896e
deprecate default args as positional in set_index
MarcoGorelli f85d72c
Merge remote-tracking branch 'upstream/master' into deprecate-nonkeyw…
MarcoGorelli f4da184
assert result in test
MarcoGorelli 87a6f59
Merge remote-tracking branch 'upstream/master' into deprecate-nonkeyw…
MarcoGorelli 792e391
Merge branch 'master' into deprecate-nonkeyword-args-replace
jreback 9546ae8
Merge branch 'master' into deprecate-nonkeyword-args-replace
simonjayhawkins 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
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 |
---|---|---|
|
@@ -705,3 +705,13 @@ def test_set_index_periodindex(self): | |
tm.assert_index_equal(df.index, idx1) | ||
df = df.set_index(idx2) | ||
tm.assert_index_equal(df.index, idx2) | ||
|
||
def test_drop_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 set_index except for " | ||
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. and the comment on the other PRs about the message. |
||
r"the arguments 'self' and 'keys' will be keyword-only" | ||
) | ||
with tm.assert_produces_warning(FutureWarning, match=msg): | ||
df.set_index("a", True) |
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.
do we set the version in other deprecations? I don't think we generally want to, for example what if we delayed this to 3.0 then we'd have to update all of these messages.
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 think in general it is useful information to mention the version when it is going to be removed)
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.
what our deprecation policy does say
out deprecation policy also says
what our deprecation policy does NOT say is what happens when the deprecation is introduced late in the series and there are no further releases in the series.
so if our next release after 1.3 (where these deprecations are introduced) is 2.0, do we deprecate the behaviour? "Deprecations will only be enforced in major releases." so the next major release is 3.0.
if the next release is 1.4, then OK to deprecate in 2.0?
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 would've thought it would be OK to deprecate in 2.0 regardless of whether there's a 1.4 release
If the deprecation is introduced in 1.3.0 (minor release) and then enforced in 2.0 (the next major release), then isn't that inline with the policy?
I don't understand how you got to "so the next major release is 3.0"
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 yet another reason we don't want to actually use the version string in the message
in any event we can choose or not to release 1.4 (no depreciations removed ) or just do 2.0 (where all depreciations are removed)
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 recall a comment from Joris that we should not expect all users to upgrade to every version and that users could skip versions.
so if we introduce in one version, should we enforce in the next?