From a26065859de169fdab0e6f0719d44022944fd64a Mon Sep 17 00:00:00 2001 From: KeiOshima Date: Thu, 25 Apr 2024 15:14:48 -0400 Subject: [PATCH 1/2] DOC: fixing SA01 error for Index: T and empty --- ci/code_checks.sh | 2 -- pandas/core/base.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index e2d125ad1fc68..2ae3ec34b3958 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -113,7 +113,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.DatetimeTZDtype.tz SA01" \ -i "pandas.Grouper PR02" \ -i "pandas.Index PR07" \ - -i "pandas.Index.T SA01" \ -i "pandas.Index.append PR07,RT03,SA01" \ -i "pandas.Index.copy PR07,SA01" \ -i "pandas.Index.difference PR07,RT03,SA01" \ @@ -122,7 +121,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Index.droplevel RT03,SA01" \ -i "pandas.Index.dropna RT03,SA01" \ -i "pandas.Index.duplicated RT03" \ - -i "pandas.Index.empty GL08" \ -i "pandas.Index.get_indexer PR07,SA01" \ -i "pandas.Index.get_indexer_for PR01,SA01" \ -i "pandas.Index.get_indexer_non_unique PR07,SA01" \ diff --git a/pandas/core/base.py b/pandas/core/base.py index ab27248308d74..72d8c1b837398 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -309,6 +309,10 @@ def transpose(self, *args, **kwargs) -> Self: doc=""" Return the transpose, which is by definition self. + See Also + -------- + Index : Immutable sequence used for indexing and alignment. + Examples -------- For Series: @@ -691,6 +695,40 @@ def to_numpy( @final @property def empty(self) -> bool: + """ + Indicator whether Index is empty. + + Returns + ------- + bool + If Index is empty, return True, if not return False. + + See Also + -------- + Index.size : Return the number of elements in the underlying data. + + Examples + -------- + >>> idx_empty = pd.Index([1, 2, 3]) + >>> idx_empty + Index([1, 2, 3], dtype='int64') + >>> idx_empty.empty + False + + >>> idx_empty = pd.Index([]) + >>> idx_empty + Index([], dtype='object') + >>> idx_empty.empty + True + + If we only have NaNs in our DataFrame, it is not considered empty! + + >>> idx_empty = pd.Index([np.nan, np.nan]) + >>> idx_empty + Index([nan, nan], dtype='float64') + >>> idx_empty.empty + False + """ return not self.size @doc(op="max", oppose="min", value="largest") From 83ccda7b4a3519543687dde73f260bf6c1820eb9 Mon Sep 17 00:00:00 2001 From: KeiOshima Date: Thu, 25 Apr 2024 15:42:44 -0400 Subject: [PATCH 2/2] fixing EXPECTED TO FAIL, BUT NOT FAILING error --- ci/code_checks.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 2ae3ec34b3958..d5371a96c66ce 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -232,7 +232,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.RangeIndex.step SA01" \ -i "pandas.RangeIndex.stop SA01" \ -i "pandas.Series SA01" \ - -i "pandas.Series.T SA01" \ -i "pandas.Series.__iter__ RT03,SA01" \ -i "pandas.Series.add PR07" \ -i "pandas.Series.at_time PR01" \ @@ -273,7 +272,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.dt.tz_localize PR01,PR02" \ -i "pandas.Series.dt.unit GL08" \ -i "pandas.Series.dtype SA01" \ - -i "pandas.Series.empty GL08" \ -i "pandas.Series.eq PR07,SA01" \ -i "pandas.Series.floordiv PR07" \ -i "pandas.Series.ge PR07,SA01" \