Skip to content

Commit 2ed1f28

Browse files
tadejaTomAugspurger
authored andcommitted
DOC: Explicitly include "private" ExtensionArray methods in API docs (#27279)
1 parent c104a0c commit 2ed1f28

File tree

3 files changed

+90
-12
lines changed

3 files changed

+90
-12
lines changed

doc/source/reference/extensions.rst

+35-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,44 @@ objects.
1818
api.extensions.register_series_accessor
1919
api.extensions.register_index_accessor
2020
api.extensions.ExtensionDtype
21-
api.extensions.ExtensionArray
2221

2322
.. autosummary::
2423
:toctree: api/
2524
:template: autosummary/class_without_autosummary.rst
2625

26+
api.extensions.ExtensionArray
2727
arrays.PandasArray
28+
29+
.. We need this autosummary so that methods and attributes are generated.
30+
.. Separate block, since they aren't classes.
31+
32+
.. autosummary::
33+
:toctree: api/
34+
35+
api.extensions.ExtensionArray._concat_same_type
36+
api.extensions.ExtensionArray._formatter
37+
api.extensions.ExtensionArray._formatting_values
38+
api.extensions.ExtensionArray._from_factorized
39+
api.extensions.ExtensionArray._from_sequence
40+
api.extensions.ExtensionArray._from_sequence_of_strings
41+
api.extensions.ExtensionArray._ndarray_values
42+
api.extensions.ExtensionArray._reduce
43+
api.extensions.ExtensionArray._values_for_argsort
44+
api.extensions.ExtensionArray._values_for_factorize
45+
api.extensions.ExtensionArray.argsort
46+
api.extensions.ExtensionArray.astype
47+
api.extensions.ExtensionArray.copy
48+
api.extensions.ExtensionArray.dropna
49+
api.extensions.ExtensionArray.factorize
50+
api.extensions.ExtensionArray.fillna
51+
api.extensions.ExtensionArray.isna
52+
api.extensions.ExtensionArray.ravel
53+
api.extensions.ExtensionArray.repeat
54+
api.extensions.ExtensionArray.searchsorted
55+
api.extensions.ExtensionArray.shift
56+
api.extensions.ExtensionArray.take
57+
api.extensions.ExtensionArray.unique
58+
api.extensions.ExtensionArray.dtype
59+
api.extensions.ExtensionArray.nbytes
60+
api.extensions.ExtensionArray.ndim
61+
api.extensions.ExtensionArray.shape

pandas/core/arrays/base.py

+53-9
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,39 @@ class ExtensionArray:
3939
4040
.. versionadded:: 0.23.0
4141
42+
Attributes
43+
----------
44+
dtype
45+
nbytes
46+
ndim
47+
shape
48+
49+
Methods
50+
-------
51+
argsort
52+
astype
53+
copy
54+
dropna
55+
factorize
56+
fillna
57+
isna
58+
ravel
59+
repeat
60+
searchsorted
61+
shift
62+
take
63+
unique
64+
_concat_same_type
65+
_formatter
66+
_formatting_values
67+
_from_factorized
68+
_from_sequence
69+
_from_sequence_of_strings
70+
_ndarray_values
71+
_reduce
72+
_values_for_argsort
73+
_values_for_factorize
74+
4275
Notes
4376
-----
4477
The interface includes the following abstract methods that must be
@@ -170,7 +203,6 @@ def _from_sequence_of_strings(cls, strings, dtype=None, copy=False):
170203
Returns
171204
-------
172205
ExtensionArray
173-
174206
"""
175207
raise AbstractMethodError(cls)
176208

@@ -188,7 +220,7 @@ def _from_factorized(cls, values, original):
188220
189221
See Also
190222
--------
191-
pandas.factorize
223+
factorize
192224
ExtensionArray.factorize
193225
"""
194226
raise AbstractMethodError(cls)
@@ -654,7 +686,7 @@ def factorize(self, na_sentinel: int = -1) -> Tuple[np.ndarray, ABCExtensionArra
654686
655687
See Also
656688
--------
657-
pandas.factorize : Top-level factorize method that dispatches here.
689+
factorize : Top-level factorize method that dispatches here.
658690
659691
Notes
660692
-----
@@ -778,18 +810,18 @@ def take(
778810
When `indices` contains negative values other than ``-1``
779811
and `allow_fill` is True.
780812
813+
See Also
814+
--------
815+
numpy.take
816+
api.extensions.take
817+
781818
Notes
782819
-----
783820
ExtensionArray.take is called by ``Series.__getitem__``, ``.loc``,
784821
``iloc``, when `indices` is a sequence of values. Additionally,
785822
it's called by :meth:`Series.reindex`, or any other method
786823
that causes realignment, with a `fill_value`.
787824
788-
See Also
789-
--------
790-
numpy.take
791-
pandas.api.extensions.take
792-
793825
Examples
794826
--------
795827
Here's an example implementation, which relies on casting the
@@ -862,7 +894,7 @@ def _formatter(self, boxed: bool = False) -> Callable[[Any], Optional[str]]:
862894
863895
Parameters
864896
----------
865-
boxed: bool, default False
897+
boxed : bool, default False
866898
An indicated for whether or not your array is being printed
867899
within a Series, DataFrame, or Index (True), or just by
868900
itself (False). This may be useful if you want scalar values
@@ -889,6 +921,10 @@ def _formatting_values(self) -> np.ndarray:
889921
.. deprecated:: 0.24.0
890922
891923
Use :meth:`ExtensionArray._formatter` instead.
924+
925+
Returns
926+
-------
927+
array : ndarray
892928
"""
893929
return np.array(self)
894930

@@ -904,6 +940,10 @@ def ravel(self, order="C") -> ABCExtensionArray:
904940
----------
905941
order : {None, 'C', 'F', 'A', 'K'}, default 'C'
906942
943+
Returns
944+
-------
945+
ExtensionArray
946+
907947
Notes
908948
-----
909949
- Because ExtensionArrays are 1D-only, this is a no-op.
@@ -944,6 +984,10 @@ def _ndarray_values(self) -> np.ndarray:
944984
945985
The expectation is that this is cheap to compute, and is primarily
946986
used for interacting with our indexers.
987+
988+
Returns
989+
-------
990+
array : ndarray
947991
"""
948992
return np.array(self)
949993

pandas/core/indexes/category.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,12 @@ def _is_dtype_compat(self, other):
306306

307307
def equals(self, other):
308308
"""
309-
Determine if two CategorialIndex objects contain the same elements.
309+
Determine if two CategoricalIndex objects contain the same elements.
310310
311311
Returns
312312
-------
313313
bool
314-
If two CategorialIndex objects have equal elements True,
314+
If two CategoricalIndex objects have equal elements True,
315315
otherwise False.
316316
"""
317317
if self.is_(other):

0 commit comments

Comments
 (0)