Skip to content

Commit 273c8c6

Browse files
authored
DOC: Fixing EX01 - Added examples (#54205)
* Examples ExtensionArray.ndim ... * Correct tolist
1 parent c1f673b commit 273c8c6

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

ci/code_checks.sh

-4
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
9999
pandas.api.extensions.ExtensionDtype \
100100
pandas.api.extensions.ExtensionArray \
101101
pandas.arrays.NumpyExtensionArray \
102-
pandas.api.extensions.ExtensionArray._accumulate \
103102
pandas.api.extensions.ExtensionArray._concat_same_type \
104103
pandas.api.extensions.ExtensionArray._formatter \
105104
pandas.api.extensions.ExtensionArray._from_factorized \
@@ -110,9 +109,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
110109
pandas.api.extensions.ExtensionArray._values_for_factorize \
111110
pandas.api.extensions.ExtensionArray.interpolate \
112111
pandas.api.extensions.ExtensionArray.ravel \
113-
pandas.api.extensions.ExtensionArray.ndim \
114-
pandas.api.extensions.ExtensionArray.shape \
115-
pandas.api.extensions.ExtensionArray.tolist \
116112
pandas.DataFrame.__dataframe__
117113
RET=$(($RET + $?)) ; echo $MSG "DONE"
118114

pandas/core/arrays/base.py

+26
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,12 @@ def dtype(self) -> ExtensionDtype:
520520
def shape(self) -> Shape:
521521
"""
522522
Return a tuple of the array dimensions.
523+
524+
Examples
525+
--------
526+
>>> arr = pd.array([1, 2, 3])
527+
>>> arr.shape
528+
(3,)
523529
"""
524530
return (len(self),)
525531

@@ -536,6 +542,12 @@ def size(self) -> int:
536542
def ndim(self) -> int:
537543
"""
538544
Extension Arrays are only allowed to be 1-dimensional.
545+
546+
Examples
547+
--------
548+
>>> arr = pd.array([1, 2, 3])
549+
>>> arr.ndim
550+
1
539551
"""
540552
return 1
541553

@@ -1599,6 +1611,14 @@ def _accumulate(
15991611
Raises
16001612
------
16011613
NotImplementedError : subclass does not define accumulations
1614+
1615+
Examples
1616+
--------
1617+
>>> arr = pd.array([1, 2, 3])
1618+
>>> arr._accumulate(name='cumsum')
1619+
<IntegerArray>
1620+
[1, 3, 6]
1621+
Length: 3, dtype: Int64
16021622
"""
16031623
raise NotImplementedError(f"cannot perform {name} with type {self.dtype}")
16041624

@@ -1694,6 +1714,12 @@ def tolist(self) -> list:
16941714
Returns
16951715
-------
16961716
list
1717+
1718+
Examples
1719+
--------
1720+
>>> arr = pd.array([1, 2, 3])
1721+
>>> arr.tolist()
1722+
[1, 2, 3]
16971723
"""
16981724
if self.ndim > 1:
16991725
return [x.tolist() for x in self]

0 commit comments

Comments
 (0)