-
-
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
DOC/CLN: Index shared docs with appending actual docstrings #20022
DOC/CLN: Index shared docs with appending actual docstrings #20022
Conversation
You can see in the second commit what actually needed to be changed in the Index docstrings. For If we want, I can keep a template for |
Should clarify when should be using _shared_docs, I agree in Index subclasses we should prob try not to use it as much as its cumbersome. Though it is nice to have the correct return class rather than Index as the generic return value. Its more informative. The problem here is that we generally do want to use shared kwargs. so its confusing that in some cases we don't and other cases we do. Should have a clear cut case here in order to NOT use them. The reason is in the future folks would just not use them, defeating the purpose of having good doc-strings. We should have a single well-defined way of doing this. Sure in some simple cases it is not needed, but then you have to decide when that is. |
With this PR it can be quite clear: for Index subclasses we don't use template substitution, for Series/Index (from IndexOpsMixin) or Series/DataFrame (from NDFrame) we do use them (for some of the methods). Of course the question is: do we want to use template substitution for Index in the future as well? Because indeed, this PR prevents that. |
see that's the thing. Why would we do this? it just adds to the confusion. Index/Series are very very similar, so to do it in Series but not Index raises questions of why? and then there is the special case of IndexOpsMixin. |
There is not much difference in practice:
vs
Anyhow, even for NDFrame, is there is actually no substitution, we would only do |
IMO this makes it more explicit. Now often there is |
@jorisvandenbossche the problem is a new contributor will have no which one to use. we need a clear unambiguous policy. it may be obvious. e.g. if the method is only defined in base.py then don't use a template / shared, otherwise do. |
def take(self, indices, axis=0, allow_fill=True, | ||
fill_value=None, **kwargs): | ||
""" | ||
return a new Index of the values selected by the indices |
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.
Thoughts on phrasing this as "Return a new index of the same type ..."? I suppose "of the values" implies that you're getting the same type of index back though.
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.
generally we need language to assert that we are getting back the same type of Index after the op (which is almost always true), though there are exceptions. This is technically easier to have the doc-strings render like this, e.g. PeriodIndex
is pretty explicty as a return type for example.
closing as stale. if you'd like to continue pls ping. |
Hello @jorisvandenbossche! Thanks for updating the PR.
|
I will look into rebasing this next week |
@jorisvandenbossche do you still want to rebase this? |
closing as stale, but reopen if can continue |
xref #19932 and #20016
This removed the
_index_shared_docs
dict for the Index class.There were 4 methods that actually substituted values: take, get_indexer, get_indexer_non_unique, fillna