-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
API: add top-level functions as method #12640
Comments
From the above list, Further, I don't think I find it necessary to deprecate those. Those are frequently used functions, so not sure it is worth deprecating them (which does not mean some of them would be valuable as a method as well). |
@jreback I'm interested in taking a stab at this, but since I've never toyed with The easiest way to port these to methods would be to simply thread a call to the globals from a method (akin to what is done in As I see it, the best option would be to instead move the core of each of the method bodies into a |
@ResidentMario conceptually this is very easy, (look at something like
BUT I didn't put a doc-string. And you cannot import things directly at the top-level in so here's a way to do this. create I think this is a nice pattern that will work. |
Ok, great, glad I asked! |
Line no. 186 in
Edit: actually it does generate a doc entry. Sphinx is more clever than I thought! So I think that |
Technically speaking, if reusing the original docstring is OK, this pattern could be used for all of the other conversions as well, since the files they are defined in already import that However I think that the old functions ought to get links to the new methods in their docstrings, and vice versa, and that the new methods ought to additionally get a In the case of @jreback what do you think? |
@ResidentMario yeah ok with having a standard way of doing this for doc-strings and such (so should fix So for how to do this, Ideally establish the pattern doing 1 or 2 methods, then in additional PR's can do the rest. IOW, can tweek to get the pattern that we want (and maybe make helpers / decorators to assist first). FYI, I have made a decorator e75eacb (see I am going to split this off and push to master shortly. (the decorator) |
xref #12640 xref #14876 Author: Aleksey Bilogur <aleksey.bilogur@gmail.com> Closes #15521 from ResidentMario/12640 and squashes the following commits: 1657246 [Aleksey Bilogur] two doc changes 28a38f2 [Aleksey Bilogur] tweak whatsnew entry. 5f306a9 [Aleksey Bilogur] +whatsnew ff895fe [Aleksey Bilogur] Add tests, update docs. 11f3fe4 [Aleksey Bilogur] rm stray debug. 3cbbed5 [Aleksey Bilogur] Melt docstring. d54dc2f [Aleksey Bilogur] +pd.DataFrame.melt.
still relevant? |
i think it's worth adding get_dummies (there is an existing PR for this) and cut/qcut to series - separately can consider deprecating the top level |
Discussed on today's dev call and the consensus was against, as in the time since the OP we have moved in the opposite direction towards not having e.g. DataFrame.read_csv. @mroeschke also pointed out that qcut can return one object or a tuple depending on arguments, which defeats chaining. Closing. |
xref #12578
so its pretty easy to add (and eventually deprecate) certain top-level functions that could/should be methods. Promotes a cleaner syntax and method chaining.
In 0.18.1 would propose adding these, deprecating in 0.19.0.
This would eliminate the ability to use directly with
np.ndarrays
, but I view this is as a positive (note we effectively did this for the.rolling/expanding/ewm
withnp.ndarrays
as well, though deprecated for a while).pd.crosstab
(DataFrame)pd.melt
(DataFrame) (PR API: add top-level melt function as method #15521); added toDataFrame
pd.get_dummies
(both)pd.cut/qcut
(only on Series)The text was updated successfully, but these errors were encountered: