-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: Improve code example for Index.get_indexer #21511
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: Improve code example for Index.get_indexer #21511
Conversation
Hello @topper-123! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on June 19, 2018 at 08:19 Hours UTC |
e0c60b2
to
59d66ea
Compare
Codecov Report
@@ Coverage Diff @@
## master #21511 +/- ##
=======================================
Coverage 91.92% 91.92%
=======================================
Files 153 153
Lines 49587 49587
=======================================
Hits 45583 45583
Misses 4004 4004
Continue to review full report at Codecov.
|
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.
Nice!
cc @jreback
pandas/core/indexes/base.py
Outdated
@@ -3148,8 +3148,12 @@ def droplevel(self, level=0): | |||
|
|||
Examples | |||
-------- | |||
>>> indexer = index.get_indexer(new_index) | |||
>>> new_values = cur_values.take(indexer) | |||
>>> index = %(target_klass)s(['c', 'a', 'b']) |
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.
There are docs being generated for both MultiIndex.get_indexer
and IntervalIndex.get_indexer
that are using this template:
pandas/pandas/core/indexes/multi.py
Lines 1962 to 1963 in 9e982e1
@Appender(_index_shared_docs['get_indexer'] % _index_doc_kwargs) | |
def get_indexer(self, target, method=None, limit=None, tolerance=None): |
pandas/pandas/core/indexes/interval.py
Lines 1090 to 1091 in 9e982e1
@Appender(_index_shared_docs['get_indexer'] % _index_doc_kwargs) | |
def get_indexer(self, target, method=None, limit=None, tolerance=None): |
Other indexes, like PeriodIndex
, don't appear to currently have docs generated for this, but inherit the method and would produce a docstring viewable with a command like PeriodIndex.get_indexer?
in IPython.
In any of these cases, the %(target_klass)s
(I think this should actually be %(klass)s
?) would get filled in with one of the aforementioned index types, which would produce an invalid example.
I think it's reasonable to just hardcode this in as Index(['c', 'a', 'b'])
and have the user infer the behavior for the specific type of index they're using?
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 it's reasonable to just hardcode this in as Index(['c', 'a', 'b']) and have the user infer the behavior for the specific type of index they're using?
+ 1
59d66ea
to
e2e6f39
Compare
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.
Thanks!
@topper-123 Thanks! |
Make code example clearer for
Index.get_indexer