Skip to content

Issue/26506 Provides correct desciption in docstring that get_indexer methods are not yet supported #26519

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

Merged
merged 18 commits into from
May 30, 2019
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

_index_doc_kwargs = dict(klass='Index', inplace='',
target_klass='Index',
raises_section='',
unique='Index', duplicated='np.ndarray')
_index_shared_docs = dict()

Expand Down Expand Up @@ -2788,7 +2789,7 @@ def get_loc(self, key, method=None, tolerance=None):
positions matches the corresponding target values. Missing values
in the target are marked by -1.

Examples
%(raises_section)sExamples
--------
>>> index = pd.Index(['c', 'a', 'b'])
>>> index.get_indexer(['a', 'b', 'x'])
Expand Down
14 changes: 12 additions & 2 deletions pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from pandas._libs import Timedelta, Timestamp
from pandas._libs.interval import Interval, IntervalMixin, IntervalTree
from pandas.util._decorators import Appender, cache_readonly
from pandas.util._decorators import Appender, Substitution, cache_readonly
from pandas.util._exceptions import rewrite_exception

from pandas.core.dtypes.cast import (
Expand Down Expand Up @@ -648,6 +648,8 @@ def _check_method(self, method):
return

if method in ['bfill', 'backfill', 'pad', 'ffill', 'nearest']:
# The documentation warns these methods are not implemented so if
# this is fixed please fix the doc string.
msg = 'method {method} not yet implemented for IntervalIndex'
raise NotImplementedError(msg.format(method=method))

Expand Down Expand Up @@ -805,7 +807,15 @@ def get_value(self, series, key):
loc = self.get_loc(key)
return series.iloc[loc]

@Appender(_index_shared_docs['get_indexer'] % _index_doc_kwargs)
@Substitution(dict(_index_doc_kwargs,
**{'raises_section': textwrap.dedent("""\
Raises
------
raises NotImplementedError if any method other than than the default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically this is formatted like

Raises
------
ExceptionName
    Condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @TomAugspurger - have adjusted accordingly

method is specified as these are not yet implemented.

""")}))
@Appender(_index_shared_docs['get_indexer'])
def get_indexer(self, target, method=None, limit=None, tolerance=None):

self._check_method(method)
Expand Down