Skip to content

Commit 06a5d9e

Browse files
committed
CLN: @doc - base.py
1 parent 5dd27ed commit 06a5d9e

File tree

4 files changed

+14
-19
lines changed

4 files changed

+14
-19
lines changed

pandas/core/arrays/categorical.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
Substitution,
1616
cache_readonly,
1717
deprecate_kwarg,
18+
doc,
1819
)
1920
from pandas.util._validators import validate_bool_kwarg, validate_fillna_kwargs
2021

@@ -51,7 +52,7 @@
5152
_extension_array_shared_docs,
5253
try_cast_to_ea,
5354
)
54-
from pandas.core.base import NoNewAttributesMixin, PandasObject, _shared_docs
55+
from pandas.core.base import IndexOpsMixin, NoNewAttributesMixin, PandasObject
5556
import pandas.core.common as com
5657
from pandas.core.construction import array, extract_array, sanitize_array
5758
from pandas.core.indexers import check_array_indexer, deprecate_ndim_indexing
@@ -1352,8 +1353,7 @@ def memory_usage(self, deep=False):
13521353
"""
13531354
return self._codes.nbytes + self.dtype.categories.memory_usage(deep=deep)
13541355

1355-
@Substitution(klass="Categorical")
1356-
@Appender(_shared_docs["searchsorted"])
1356+
@doc(IndexOpsMixin.searchsorted, klass="Categorical")
13571357
def searchsorted(self, value, side="left", sorter=None):
13581358
# searchsorted is very performance sensitive. By converting codes
13591359
# to same dtype as self.codes, we get much faster performance.

pandas/core/base.py

+7-11
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pandas.compat import PYPY
1414
from pandas.compat.numpy import function as nv
1515
from pandas.errors import AbstractMethodError
16-
from pandas.util._decorators import Appender, Substitution, cache_readonly, doc
16+
from pandas.util._decorators import cache_readonly, doc
1717
from pandas.util._validators import validate_bool_kwarg
1818

1919
from pandas.core.dtypes.cast import is_nested_object
@@ -1402,26 +1402,26 @@ def memory_usage(self, deep=False):
14021402
def factorize(self, sort=False, na_sentinel=-1):
14031403
return algorithms.factorize(self, sort=sort, na_sentinel=na_sentinel)
14041404

1405-
_shared_docs[
1406-
"searchsorted"
1407-
] = """
1405+
@doc(klass="Index")
1406+
def searchsorted(self, value, side="left", sorter=None) -> np.ndarray:
1407+
"""
14081408
Find indices where elements should be inserted to maintain order.
14091409
1410-
Find the indices into a sorted %(klass)s `self` such that, if the
1410+
Find the indices into a sorted {klass} `self` such that, if the
14111411
corresponding elements in `value` were inserted before the indices,
14121412
the order of `self` would be preserved.
14131413
14141414
.. note::
14151415
1416-
The %(klass)s *must* be monotonically sorted, otherwise
1416+
The {klass} *must* be monotonically sorted, otherwise
14171417
wrong locations will likely be returned. Pandas does *not*
14181418
check this for you.
14191419
14201420
Parameters
14211421
----------
14221422
value : array_like
14231423
Values to insert into `self`.
1424-
side : {'left', 'right'}, optional
1424+
side : {{'left', 'right'}}, optional
14251425
If 'left', the index of the first suitable location found is given.
14261426
If 'right', return the last such index. If there is no suitable
14271427
index, return either 0 or N (where N is the length of `self`).
@@ -1488,10 +1488,6 @@ def factorize(self, sort=False, na_sentinel=-1):
14881488
>>> x.searchsorted(1)
14891489
0 # wrong result, correct would be 1
14901490
"""
1491-
1492-
@Substitution(klass="Index")
1493-
@Appender(_shared_docs["searchsorted"])
1494-
def searchsorted(self, value, side="left", sorter=None) -> np.ndarray:
14951491
return algorithms.searchsorted(self._values, value, side=side, sorter=sorter)
14961492

14971493
def drop_duplicates(self, keep="first", inplace=False):

pandas/core/indexes/datetimelike.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pandas._libs.tslibs import timezones
1111
from pandas.compat.numpy import function as nv
1212
from pandas.errors import AbstractMethodError
13-
from pandas.util._decorators import Appender, cache_readonly
13+
from pandas.util._decorators import Appender, cache_readonly, doc
1414

1515
from pandas.core.dtypes.common import (
1616
ensure_int64,
@@ -31,7 +31,7 @@
3131
from pandas.core import algorithms
3232
from pandas.core.arrays import DatetimeArray, PeriodArray, TimedeltaArray
3333
from pandas.core.arrays.datetimelike import DatetimeLikeArrayMixin
34-
from pandas.core.base import _shared_docs
34+
from pandas.core.base import IndexOpsMixin
3535
import pandas.core.indexes.base as ibase
3636
from pandas.core.indexes.base import Index, _index_shared_docs
3737
from pandas.core.indexes.extension import (
@@ -206,7 +206,7 @@ def take(self, indices, axis=0, allow_fill=True, fill_value=None, **kwargs):
206206
self, indices, axis, allow_fill, fill_value, **kwargs
207207
)
208208

209-
@Appender(_shared_docs["searchsorted"])
209+
@doc(IndexOpsMixin.searchsorted, klass="Datetime Index")
210210
def searchsorted(self, value, side="left", sorter=None):
211211
if isinstance(value, str):
212212
raise TypeError(

pandas/core/series.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2470,8 +2470,7 @@ def __rmatmul__(self, other):
24702470
"""
24712471
return self.dot(np.transpose(other))
24722472

2473-
@Substitution(klass="Series")
2474-
@Appender(base._shared_docs["searchsorted"])
2473+
@doc(base.IndexOpsMixin.searchsorted, klass="Series")
24752474
def searchsorted(self, value, side="left", sorter=None):
24762475
return algorithms.searchsorted(self._values, value, side=side, sorter=sorter)
24772476

0 commit comments

Comments
 (0)