From 5dedc6453dc050fb94c5d930c0afa5aa09dfff3b Mon Sep 17 00:00:00 2001 From: Dea Leon Date: Tue, 21 Feb 2023 14:26:26 +0100 Subject: [PATCH] DOC Fix EX01 issues in docstrings --- ci/code_checks.sh | 4 ---- pandas/core/base.py | 47 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 0333975ed269f..6961d77bebd3d 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -86,10 +86,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then MSG='Partially validate docstrings (EX01)' ; echo $MSG $BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01 --ignore_functions \ pandas.Series.index \ - pandas.Series.nbytes \ - pandas.Series.ndim \ - pandas.Series.size \ - pandas.Series.T \ pandas.Series.hasnans \ pandas.Series.to_list \ pandas.Series.__iter__ \ diff --git a/pandas/core/base.py b/pandas/core/base.py index 7093f2ceca50b..6bed382f54e4b 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -301,6 +301,20 @@ def transpose(self: _T, *args, **kwargs) -> _T: transpose, doc=""" Return the transpose, which is by definition self. + + Examples + -------- + >>> s = pd.Series(['Ant', 'Bear', 'Cow']) + >>> s + 0 Ant + 1 Bear + 2 Cow + dtype: object + >>> s.T + 0 Ant + 1 Bear + 2 Cow + dtype: object """, ) @@ -325,6 +339,17 @@ def __len__(self) -> int: def ndim(self) -> Literal[1]: """ Number of dimensions of the underlying data, by definition 1. + + Examples + -------- + >>> s = pd.Series(['Ant', 'Bear', 'Cow']) + >>> s + 0 Ant + 1 Bear + 2 Cow + dtype: object + >>> s.ndim + 1 """ return 1 @@ -351,6 +376,17 @@ def item(self): def nbytes(self) -> int: """ Return the number of bytes in the underlying data. + + Examples + -------- + >>> s = pd.Series(['Ant', 'Bear', 'Cow']) + >>> s + 0 Ant + 1 Bear + 2 Cow + dtype: object + >>> s.nbytes + 24 """ return self._values.nbytes @@ -358,6 +394,17 @@ def nbytes(self) -> int: def size(self) -> int: """ Return the number of elements in the underlying data. + + Examples + -------- + >>> s = pd.Series(['Ant', 'Bear', 'Cow']) + >>> s + 0 Ant + 1 Bear + 2 Cow + dtype: object + >>> s.size + 3 """ return len(self._values)