-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
API: add top-level functions as method #15513
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
Conversation
Note: this conversation is continued from #12640. This is a PR which aliases certain top-level functions into The top-level method bodies remain in the tooling libraries in which they were defined before, but the docstrings have been moved to This is done so that the docstrings between the top-level and object-method differ in two respects:
This reuses an earlier-established convention used elsewhere throughout the library. Have not written nor attempted to pass tests just yet. That being said, in the conversation on the issue @jreback mentions tweaking the pattern by possible e.g. using another newly created decorator. I agree that this could be a smart change, because the use of In this PR: Not in this PR: Finally, |
@ResidentMario to address a point that you made. When we have a shared method that is needed for both Series & DataFrame, we actually put it in |
alternatively, since some of our files (e.g.
|
Re: Re: globing off the docs, I don't have a strong opinion on this. Having a file for docstrings is weird, but then again, so is having docstrings floating somewhere about their method bodies :). It would certainly make things significantly cleaner, architecturally. I wouldn't mind implementing either/or. The latter kind of sounds like a different PR, though. |
@ResidentMario yep go ahead and make changes to move things to |
Sorry that I didn't raise my concert earlier on the issue, and @ResidentMario I find it difficult to give this backlash given the very nice effort you are putting in this issue. |
Regarding the docstrings, that's something I also already thought about once. Our current infrastructure of shared_docs is a bit of a mess for contributors, and can use some rethinking. But that indeed sounds like another issue/PR. In case of |
So long as you agree with the method chaining philosophy, the ability to use The other consideration is a broader one about API design. Where does Otherwise, It sounds like
Maybe the agreement to be reached here is on which of these "ought" to be where? cc: @TomAugspurger |
so most of the functions on the list, should certainly be top-level, and yes we should have a clear policy. One easy differentiator is a function which only takes a single argument, that is a Series OR a DataFrame only
In fact I would go as far as deprecating So I agree there is much confusion here on what should be where. Another example, we used to have only @jorisvandenbossche is right that we have too many methods as it is, BUT, I still think we need to clean this up and have as much consistency as possible. |
Codecov Report
@@ Coverage Diff @@
## master #15513 +/- ##
==========================================
- Coverage 90.36% 90.36% -0.01%
==========================================
Files 136 136
Lines 49553 49587 +34
==========================================
+ Hits 44780 44807 +27
- Misses 4773 4780 +7
Continue to review full report at Codecov.
|
I think the alternative of |
Oof, my bad there with the method signature. I still don't want to have to use |
Alright, I've added commits for each of the functions. Whichever ones we decide to transfer can be cherry-picked off the pull request.
Tests still TBD, pending further discussion (?). |
@jreback I think you are missing a few methods on DataFrame :-) A bit more specific concerns:
I would also not move the |
@jorisvandenbossche you can see how much I use yeah I think main method that needs inclusion is and agree on ok @ResidentMario can you strip out just |
643d54b
to
d80275d
Compare
I'll open a new PR with just the |
closes API: add top-level functions as method #12640
tests added / passed
passes
git diff upstream/master | flake8 --diff
whatsnew entry