-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
Deprecate non-keyword arguments for methods with inplace
#41485
Comments
inplace
inplace
I would like to work on this issue, it would be my first contribution to Pandas. It could take me a week or two. If that is unacceptable, feel free to assign this to someone else. |
This comment has been minimized.
This comment has been minimized.
Awesome! @jmholzer please start by choosing one of the methods listed above, and comment here which one you've chosen No need to comment 'take' here, many people will be working on this one together |
Sorry, didn't see the 'what to do' edit. eval, as it's first ;) |
Adding the pandas.util._decorators.deprecate_nonkeyword_arguments decorator to eval seemed to cause it to break (could not run example in docs, tested before and after adding decorator, ensuring decorator was only change). I can open an issue if anyone else would like to confirm. To sanity check my method, I went through the process above for drop_duplicates (in frame and series) without any problems, I have opened a pull request (#41500) for these changes. |
Thanks for looking into this - I just tried it, and confirm that it breaks for me too. Let's skip |
Is someone already in this or can I try? |
Hey @Anupam-USP - feel free to take any of the non-ticked methods |
@MarcoGorelli I am not confident that I did the pull request correctly. I only completed the first two instructions, and I didn't use the gist you created. |
Hi @MarcoGorelli I'd like to work on the two |
Hi @Anupam-USP - are you still working on resample.interpolate? |
No @MarcoGorelli, you suggested me to do read_csv. So should I go for it now? |
I wrote
so if you wanted to do this one too, that would be welcome |
Okay! Surely I will try it |
may I try working on the read_table? |
go ahead, thanks! see what's been done for |
@MarcoGorelli can you confirm just #41699 and #41718 outstanding. |
@simonjayhawkins that's right (and the clean of up these whatsnew entries, but I can do that later today) |
Only eval is left. Should I take it? |
if you can figure out how to do it, then sure - it's a bit tricker though, I'm not sure myself why it was failing when I tried it earlier |
@MarcoGorelli Thanks for coordinating this effort. i'll close this, maybe open an issue for pandas/core/computation/eval.py |
Background
Having many parameters with defaults makes static typing a lot harder when one of them changes the return type, as they require many* overloads.
There's still no broad agreement about whether or not to deprecate the
inplace
argument, so in the meanwhile, if we force default-arguments to be keyword-only, then we can at least set the correct return types for these methods without requiring all these overloads (as many as 38 in one case!).What to do
Use
pandas.util._decorators.deprecate_nonkeyword_arguments
to issue a FutureWarning that the method's default arguments will be keyword-only in the next release.Fixup any tests / internal code which uses such default arguments positionally. See this gist for a helper-script which can help identify cases which need fixing, just replace
"drop"
with whatever method you're working on and then run it aspython visitor.py
.Add a new test, checking that a FutureWarning is raised if this method's default arguments are used positionally.
Add a note to
doc/source/whatsnew/v1.3.0.rst
See #41511 for an example of how to do this.
In most of these methods, the first argument is probably fine to be kept as is, it's the ones after that (such as
axis
) which should become keyword-only.*(2^{number of default types preceding the one to overload} +2)
It's really common to call
replace
with bothvalue
andto_replace
as positional, so I think we can make an exception for that one. It'll only require 6 overloads, which I'd argue isn't too many, especially if no other method requires more than 3 or 4TODO: unify the whatsnew entries
The text was updated successfully, but these errors were encountered: