Skip to content

Commit 2deba19

Browse files
authored
DOC Fix EX01 issues in docstrings (pandas-dev#51533)
1 parent 87fd0b5 commit 2deba19

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

ci/code_checks.sh

-4
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
8686
MSG='Partially validate docstrings (EX01)' ; echo $MSG
8787
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01 --ignore_functions \
8888
pandas.Series.index \
89-
pandas.Series.nbytes \
90-
pandas.Series.ndim \
91-
pandas.Series.size \
92-
pandas.Series.T \
9389
pandas.Series.hasnans \
9490
pandas.Series.to_list \
9591
pandas.Series.__iter__ \

pandas/core/base.py

+47
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,20 @@ def transpose(self: _T, *args, **kwargs) -> _T:
301301
transpose,
302302
doc="""
303303
Return the transpose, which is by definition self.
304+
305+
Examples
306+
--------
307+
>>> s = pd.Series(['Ant', 'Bear', 'Cow'])
308+
>>> s
309+
0 Ant
310+
1 Bear
311+
2 Cow
312+
dtype: object
313+
>>> s.T
314+
0 Ant
315+
1 Bear
316+
2 Cow
317+
dtype: object
304318
""",
305319
)
306320

@@ -325,6 +339,17 @@ def __len__(self) -> int:
325339
def ndim(self) -> Literal[1]:
326340
"""
327341
Number of dimensions of the underlying data, by definition 1.
342+
343+
Examples
344+
--------
345+
>>> s = pd.Series(['Ant', 'Bear', 'Cow'])
346+
>>> s
347+
0 Ant
348+
1 Bear
349+
2 Cow
350+
dtype: object
351+
>>> s.ndim
352+
1
328353
"""
329354
return 1
330355

@@ -351,13 +376,35 @@ def item(self):
351376
def nbytes(self) -> int:
352377
"""
353378
Return the number of bytes in the underlying data.
379+
380+
Examples
381+
--------
382+
>>> s = pd.Series(['Ant', 'Bear', 'Cow'])
383+
>>> s
384+
0 Ant
385+
1 Bear
386+
2 Cow
387+
dtype: object
388+
>>> s.nbytes
389+
24
354390
"""
355391
return self._values.nbytes
356392

357393
@property
358394
def size(self) -> int:
359395
"""
360396
Return the number of elements in the underlying data.
397+
398+
Examples
399+
--------
400+
>>> s = pd.Series(['Ant', 'Bear', 'Cow'])
401+
>>> s
402+
0 Ant
403+
1 Bear
404+
2 Cow
405+
dtype: object
406+
>>> s.size
407+
3
361408
"""
362409
return len(self._values)
363410

0 commit comments

Comments
 (0)