diff --git a/ci/code_checks.sh b/ci/code_checks.sh index e2d125ad1fc68..d5371a96c66ce 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" \ @@ -234,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" \ @@ -275,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" \ 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")