From 0428d74def090eb2c4e8ec19d3bb7c8ff2d60af2 Mon Sep 17 00:00:00 2001 From: KeiOshima Date: Fri, 19 Apr 2024 22:04:35 -0400 Subject: [PATCH 1/3] Doc: fixing SA01 for index.size, shape, and ndim --- ci/code_checks.sh | 3 --- pandas/core/base.py | 14 ++++++++++++++ pandas/core/indexes/base.py | 7 +++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index f446a09f2f5ea..9120700b9ea95 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -178,13 +178,10 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Index.name SA01" \ -i "pandas.Index.names GL08" \ -i "pandas.Index.nbytes SA01" \ - -i "pandas.Index.ndim SA01" \ -i "pandas.Index.nunique RT03" \ -i "pandas.Index.putmask PR01,RT03" \ -i "pandas.Index.ravel PR01,RT03" \ -i "pandas.Index.reindex PR07" \ - -i "pandas.Index.shape SA01" \ - -i "pandas.Index.size SA01" \ -i "pandas.Index.slice_indexer PR07,RT03,SA01" \ -i "pandas.Index.slice_locs RT03" \ -i "pandas.Index.str PR01,SA01" \ diff --git a/pandas/core/base.py b/pandas/core/base.py index 95b203590b393..b375e9fcb640a 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -355,6 +355,13 @@ def ndim(self) -> Literal[1]: """ Number of dimensions of the underlying data, by definition 1. + See Also + -------- + Index.size: Return the number of elements in the underlying data. + Index.shape: Return a tuple of the shape of the underlying data. + Index.dtype: Return the dtype object of the underlying data. + Index.values: Return an array representing the data in the Index. + Examples -------- >>> s = pd.Series(["Ant", "Bear", "Cow"]) @@ -440,6 +447,13 @@ def size(self) -> int: """ Return the number of elements in the underlying data. + See Also + -------- + Index.ndim: Number of dimensions of the underlying data, by definition 1. + Index.shape: Return a tuple of the shape of the underlying data. + Index.dtype: Return the dtype object of the underlying data. + Index.values: Return an array representing the data in the Index. + Examples -------- For Series: diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 685291e690196..8ede401f37184 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -7104,6 +7104,13 @@ def shape(self) -> Shape: """ Return a tuple of the shape of the underlying data. + See Also + -------- + Index.size: Return the number of elements in the underlying data. + Index.ndim: Number of dimensions of the underlying data, by definition 1. + Index.dtype: Return the dtype object of the underlying data. + Index.values: Return an array representing the data in the Index. + Examples -------- >>> idx = pd.Index([1, 2, 3]) From e307ba33b699da61e53f924d40eddd150e5b4f63 Mon Sep 17 00:00:00 2001 From: KeiOshima Date: Fri, 19 Apr 2024 22:50:41 -0400 Subject: [PATCH 2/3] EXPECTED TO FAIL, BUT NOT FAILING --- ci/code_checks.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 9120700b9ea95..55e0c9e8646c5 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -358,7 +358,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.mode SA01" \ -i "pandas.Series.mul PR07" \ -i "pandas.Series.nbytes SA01" \ - -i "pandas.Series.ndim SA01" \ -i "pandas.Series.ne PR07,SA01" \ -i "pandas.Series.nunique RT03" \ -i "pandas.Series.pad PR01,SA01" \ @@ -378,7 +377,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.rtruediv PR07" \ -i "pandas.Series.sem PR01,RT03,SA01" \ -i "pandas.Series.shape SA01" \ - -i "pandas.Series.size SA01" \ -i "pandas.Series.skew RT03,SA01" \ -i "pandas.Series.sparse PR01,SA01" \ -i "pandas.Series.sparse.density SA01" \ From 22450c39059522b004369dd155e4be2da3ceb680 Mon Sep 17 00:00:00 2001 From: KeiOshima Date: Sat, 20 Apr 2024 14:15:41 -0400 Subject: [PATCH 3/3] changing from Index to Series for core/basy.py --- pandas/core/base.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pandas/core/base.py b/pandas/core/base.py index b375e9fcb640a..9b1251a4ef5d8 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -357,10 +357,10 @@ def ndim(self) -> Literal[1]: See Also -------- - Index.size: Return the number of elements in the underlying data. - Index.shape: Return a tuple of the shape of the underlying data. - Index.dtype: Return the dtype object of the underlying data. - Index.values: Return an array representing the data in the Index. + Series.size: Return the number of elements in the underlying data. + Series.shape: Return a tuple of the shape of the underlying data. + Series.dtype: Return the dtype object of the underlying data. + Series.values: Return Series as ndarray or ndarray-like depending on the dtype. Examples -------- @@ -449,10 +449,10 @@ def size(self) -> int: See Also -------- - Index.ndim: Number of dimensions of the underlying data, by definition 1. - Index.shape: Return a tuple of the shape of the underlying data. - Index.dtype: Return the dtype object of the underlying data. - Index.values: Return an array representing the data in the Index. + Series.ndim: Number of dimensions of the underlying data, by definition 1. + Series.shape: Return a tuple of the shape of the underlying data. + Series.dtype: Return the dtype object of the underlying data. + Series.values: Return Series as ndarray or ndarray-like depending on the dtype. Examples --------