diff --git a/doc/source/reference/extensions.rst b/doc/source/reference/extensions.rst index 34f76642119c8..407aab4bb1f1b 100644 --- a/doc/source/reference/extensions.rst +++ b/doc/source/reference/extensions.rst @@ -18,10 +18,44 @@ objects. api.extensions.register_series_accessor api.extensions.register_index_accessor api.extensions.ExtensionDtype - api.extensions.ExtensionArray .. autosummary:: :toctree: api/ :template: autosummary/class_without_autosummary.rst + api.extensions.ExtensionArray arrays.PandasArray + +.. We need this autosummary so that methods and attributes are generated. +.. Separate block, since they aren't classes. + + .. autosummary:: + :toctree: api/ + + api.extensions.ExtensionArray._concat_same_type + api.extensions.ExtensionArray._formatter + api.extensions.ExtensionArray._formatting_values + api.extensions.ExtensionArray._from_factorized + api.extensions.ExtensionArray._from_sequence + api.extensions.ExtensionArray._from_sequence_of_strings + api.extensions.ExtensionArray._ndarray_values + api.extensions.ExtensionArray._reduce + api.extensions.ExtensionArray._values_for_argsort + api.extensions.ExtensionArray._values_for_factorize + api.extensions.ExtensionArray.argsort + api.extensions.ExtensionArray.astype + api.extensions.ExtensionArray.copy + api.extensions.ExtensionArray.dropna + api.extensions.ExtensionArray.factorize + api.extensions.ExtensionArray.fillna + api.extensions.ExtensionArray.isna + api.extensions.ExtensionArray.ravel + api.extensions.ExtensionArray.repeat + api.extensions.ExtensionArray.searchsorted + api.extensions.ExtensionArray.shift + api.extensions.ExtensionArray.take + api.extensions.ExtensionArray.unique + api.extensions.ExtensionArray.dtype + api.extensions.ExtensionArray.nbytes + api.extensions.ExtensionArray.ndim + api.extensions.ExtensionArray.shape diff --git a/pandas/core/arrays/base.py b/pandas/core/arrays/base.py index 2a5556ff6d357..ee796f9896b52 100644 --- a/pandas/core/arrays/base.py +++ b/pandas/core/arrays/base.py @@ -39,6 +39,39 @@ class ExtensionArray: .. versionadded:: 0.23.0 + Attributes + ---------- + dtype + nbytes + ndim + shape + + Methods + ------- + argsort + astype + copy + dropna + factorize + fillna + isna + ravel + repeat + searchsorted + shift + take + unique + _concat_same_type + _formatter + _formatting_values + _from_factorized + _from_sequence + _from_sequence_of_strings + _ndarray_values + _reduce + _values_for_argsort + _values_for_factorize + Notes ----- 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): Returns ------- ExtensionArray - """ raise AbstractMethodError(cls) @@ -188,7 +220,7 @@ def _from_factorized(cls, values, original): See Also -------- - pandas.factorize + factorize ExtensionArray.factorize """ raise AbstractMethodError(cls) @@ -654,7 +686,7 @@ def factorize(self, na_sentinel: int = -1) -> Tuple[np.ndarray, ABCExtensionArra See Also -------- - pandas.factorize : Top-level factorize method that dispatches here. + factorize : Top-level factorize method that dispatches here. Notes ----- @@ -778,6 +810,11 @@ def take( When `indices` contains negative values other than ``-1`` and `allow_fill` is True. + See Also + -------- + numpy.take + api.extensions.take + Notes ----- ExtensionArray.take is called by ``Series.__getitem__``, ``.loc``, @@ -785,11 +822,6 @@ def take( it's called by :meth:`Series.reindex`, or any other method that causes realignment, with a `fill_value`. - See Also - -------- - numpy.take - pandas.api.extensions.take - Examples -------- Here's an example implementation, which relies on casting the @@ -862,7 +894,7 @@ def _formatter(self, boxed: bool = False) -> Callable[[Any], Optional[str]]: Parameters ---------- - boxed: bool, default False + boxed : bool, default False An indicated for whether or not your array is being printed within a Series, DataFrame, or Index (True), or just by itself (False). This may be useful if you want scalar values @@ -889,6 +921,10 @@ def _formatting_values(self) -> np.ndarray: .. deprecated:: 0.24.0 Use :meth:`ExtensionArray._formatter` instead. + + Returns + ------- + array : ndarray """ return np.array(self) @@ -904,6 +940,10 @@ def ravel(self, order="C") -> ABCExtensionArray: ---------- order : {None, 'C', 'F', 'A', 'K'}, default 'C' + Returns + ------- + ExtensionArray + Notes ----- - Because ExtensionArrays are 1D-only, this is a no-op. @@ -944,6 +984,10 @@ def _ndarray_values(self) -> np.ndarray: The expectation is that this is cheap to compute, and is primarily used for interacting with our indexers. + + Returns + ------- + array : ndarray """ return np.array(self) diff --git a/pandas/core/indexes/category.py b/pandas/core/indexes/category.py index 9550d68f1d32b..ab2cd67e058b9 100644 --- a/pandas/core/indexes/category.py +++ b/pandas/core/indexes/category.py @@ -306,12 +306,12 @@ def _is_dtype_compat(self, other): def equals(self, other): """ - Determine if two CategorialIndex objects contain the same elements. + Determine if two CategoricalIndex objects contain the same elements. Returns ------- bool - If two CategorialIndex objects have equal elements True, + If two CategoricalIndex objects have equal elements True, otherwise False. """ if self.is_(other):