Skip to content

Commit 76ed611

Browse files
committed
DOC: using _shared_docs for categorical.py
1 parent 20f96f2 commit 76ed611

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

pandas/core/arrays/categorical.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
_extension_array_shared_docs,
5353
try_cast_to_ea,
5454
)
55-
from pandas.core.base import IndexOpsMixin, NoNewAttributesMixin, PandasObject
55+
from pandas.core.base import NoNewAttributesMixin, PandasObject, _shared_docs
5656
import pandas.core.common as com
5757
from pandas.core.construction import array, extract_array, sanitize_array
5858
from pandas.core.indexers import check_array_indexer, deprecate_ndim_indexing
@@ -1353,7 +1353,7 @@ def memory_usage(self, deep=False):
13531353
"""
13541354
return self._codes.nbytes + self.dtype.categories.memory_usage(deep=deep)
13551355

1356-
@doc(IndexOpsMixin.searchsorted, klass="Categorical")
1356+
@doc(_shared_docs["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

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import builtins
66
import textwrap
7-
from typing import FrozenSet, List, Optional, Union
7+
from typing import Dict, FrozenSet, List, Optional, Union
88

99
import numpy as np
1010

@@ -36,6 +36,7 @@
3636
from pandas.core.construction import create_series_with_explicit_dtype
3737
import pandas.core.nanops as nanops
3838

39+
_shared_docs: Dict[str, str] = dict()
3940
_indexops_doc_kwargs = dict(
4041
klass="IndexOpsMixin",
4142
inplace="",
@@ -1401,9 +1402,9 @@ def memory_usage(self, deep=False):
14011402
def factorize(self, sort=False, na_sentinel=-1):
14021403
return algorithms.factorize(self, sort=sort, na_sentinel=na_sentinel)
14031404

1404-
@doc(klass="Index")
1405-
def searchsorted(self, value, side="left", sorter=None) -> np.ndarray:
1406-
"""
1405+
_shared_docs[
1406+
"searchsorted"
1407+
] = """
14071408
Find indices where elements should be inserted to maintain order.
14081409
14091410
Find the indices into a sorted {klass} `self` such that, if the
@@ -1487,6 +1488,9 @@ def searchsorted(self, value, side="left", sorter=None) -> np.ndarray:
14871488
>>> x.searchsorted(1)
14881489
0 # wrong result, correct would be 1
14891490
"""
1491+
1492+
@doc(_shared_docs["searchsorted"], klass="Index")
1493+
def searchsorted(self, value, side="left", sorter=None) -> np.ndarray:
14901494
return algorithms.searchsorted(self._values, value, side=side, sorter=sorter)
14911495

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

0 commit comments

Comments
 (0)