Skip to content

Commit 01191d1

Browse files
committed
docstrings, extending docs
1 parent f7e353a commit 01191d1

File tree

3 files changed

+10
-30
lines changed

3 files changed

+10
-30
lines changed

doc/source/development/extending.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,9 @@ Implement the following:
185185
186186
def _validate_setitem_value(self, value):
187187
if pandas.api.types.is_list_like(value):
188-
return [self._validate_scalar(v) for v in value]
188+
return np.array([self._validate_scalar(v) for v in value], dtype = self.dtype)
189189
return self._validate_scalar(value)
190190
191-
def _validate_searchsorted_value(self, value):
192-
return self._validate_setitem_value(value)
193-
194191
195192
To support 2D arrays, use the ``_from_backing_data`` helper function when a
196193
method is called on multi-dimensional data of the same dtype as ``_ndarray``.

pandas/core/arrays/_mixins.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ def method(self, *args, **kwargs):
9292
class NDArrayBackedExtensionArray(NDArrayBacked, ExtensionArray):
9393
"""
9494
ExtensionArray that is backed by a single NumPy ndarray.
95+
96+
Examples
97+
--------
98+
Please see the following:
99+
100+
https://pandas.pydata.org/docs/development/extending.html#NDArrayBackedExtensionArray
95101
"""
96102

97103
_ndarray: np.ndarray
@@ -442,21 +448,8 @@ def _where(self: Self, mask: npt.NDArray[np.bool_], value) -> Self:
442448
# ------------------------------------------------------------------------
443449
# Index compat methods
444450

451+
@doc(ExtensionArray.insert)
445452
def insert(self, loc: int, item) -> Self:
446-
"""
447-
Make new ExtensionArray inserting new item at location.
448-
449-
Follows Python list.append semantics for negative values.
450-
451-
Parameters
452-
----------
453-
loc : int
454-
item : object
455-
456-
Returns
457-
-------
458-
type(self)
459-
"""
460453
loc = validate_insert_loc(loc, len(self))
461454

462455
code = self._validate_scalar(item)
@@ -475,19 +468,8 @@ def insert(self, loc: int, item) -> Self:
475468
# These are not part of the EA API, but we implement them because
476469
# pandas assumes they're there.
477470

471+
@doc(ExtensionArray.value_counts)
478472
def value_counts(self, dropna: bool = True) -> Series:
479-
"""
480-
Return a Series containing counts of unique values.
481-
482-
Parameters
483-
----------
484-
dropna : bool, default True
485-
Don't include counts of NA values.
486-
487-
Returns
488-
-------
489-
Series
490-
"""
491473
if self.ndim != 1:
492474
raise NotImplementedError
493475

pandas/tests/api/test_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ def test_api_indexers(self):
357357
def test_api_extensions(self):
358358
self.check(api_extensions, self.allowed_api_extensions)
359359

360+
360361
class TestTesting(Base):
361362
funcs = [
362363
"assert_frame_equal",

0 commit comments

Comments
 (0)