Skip to content

Commit 8f33ae0

Browse files
authored
DOC: fixing SA01 error for Index: T and empty (#58430)
* DOC: fixing SA01 error for Index: T and empty * fixing EXPECTED TO FAIL, BUT NOT FAILING error
1 parent 114845c commit 8f33ae0

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

ci/code_checks.sh

-4
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
108108
-i "pandas.DatetimeTZDtype.tz SA01" \
109109
-i "pandas.Grouper PR02" \
110110
-i "pandas.Index PR07" \
111-
-i "pandas.Index.T SA01" \
112111
-i "pandas.Index.append PR07,RT03,SA01" \
113112
-i "pandas.Index.copy PR07,SA01" \
114113
-i "pandas.Index.difference PR07,RT03,SA01" \
@@ -117,7 +116,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
117116
-i "pandas.Index.droplevel RT03,SA01" \
118117
-i "pandas.Index.dropna RT03,SA01" \
119118
-i "pandas.Index.duplicated RT03" \
120-
-i "pandas.Index.empty GL08" \
121119
-i "pandas.Index.get_indexer PR07,SA01" \
122120
-i "pandas.Index.get_indexer_for PR01,SA01" \
123121
-i "pandas.Index.get_indexer_non_unique PR07,SA01" \
@@ -229,7 +227,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
229227
-i "pandas.RangeIndex.step SA01" \
230228
-i "pandas.RangeIndex.stop SA01" \
231229
-i "pandas.Series SA01" \
232-
-i "pandas.Series.T SA01" \
233230
-i "pandas.Series.__iter__ RT03,SA01" \
234231
-i "pandas.Series.add PR07" \
235232
-i "pandas.Series.at_time PR01" \
@@ -270,7 +267,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
270267
-i "pandas.Series.dt.tz_localize PR01,PR02" \
271268
-i "pandas.Series.dt.unit GL08" \
272269
-i "pandas.Series.dtype SA01" \
273-
-i "pandas.Series.empty GL08" \
274270
-i "pandas.Series.eq PR07,SA01" \
275271
-i "pandas.Series.floordiv PR07" \
276272
-i "pandas.Series.ge PR07,SA01" \

pandas/core/base.py

+38
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ def transpose(self, *args, **kwargs) -> Self:
309309
doc="""
310310
Return the transpose, which is by definition self.
311311
312+
See Also
313+
--------
314+
Index : Immutable sequence used for indexing and alignment.
315+
312316
Examples
313317
--------
314318
For Series:
@@ -691,6 +695,40 @@ def to_numpy(
691695
@final
692696
@property
693697
def empty(self) -> bool:
698+
"""
699+
Indicator whether Index is empty.
700+
701+
Returns
702+
-------
703+
bool
704+
If Index is empty, return True, if not return False.
705+
706+
See Also
707+
--------
708+
Index.size : Return the number of elements in the underlying data.
709+
710+
Examples
711+
--------
712+
>>> idx_empty = pd.Index([1, 2, 3])
713+
>>> idx_empty
714+
Index([1, 2, 3], dtype='int64')
715+
>>> idx_empty.empty
716+
False
717+
718+
>>> idx_empty = pd.Index([])
719+
>>> idx_empty
720+
Index([], dtype='object')
721+
>>> idx_empty.empty
722+
True
723+
724+
If we only have NaNs in our DataFrame, it is not considered empty!
725+
726+
>>> idx_empty = pd.Index([np.nan, np.nan])
727+
>>> idx_empty
728+
Index([nan, nan], dtype='float64')
729+
>>> idx_empty.empty
730+
False
731+
"""
694732
return not self.size
695733

696734
@doc(op="max", oppose="min", value="largest")

0 commit comments

Comments
 (0)