Skip to content

Commit 7abd759

Browse files
committed
Add examples and notes to empty documentation
1 parent db12255 commit 7abd759

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

pandas/core/generic.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,25 @@ def __contains__(self, key):
842842

843843
@property
844844
def empty(self):
845-
"""True if NDFrame is entirely empty [no items]"""
845+
"""True if NDFrame is entirely empty [no items], i.e. all of the axes
846+
are of length 0.
847+
848+
Notes
849+
-----
850+
If NDFrame contains only NaNs, it is still not considered empty.
851+
852+
Examples
853+
--------
854+
855+
>>> # containing only NaNs does not make the df empty
856+
>>> df = pd.DataFrame({'A' : [np.nan]})
857+
>>> df.empty
858+
False
859+
>>> # if we drop NAs, the axes are now of length 0
860+
>>> df.dropna().empty
861+
True
862+
863+
"""
846864
return not all(len(self._get_axis(a)) > 0 for a in self._AXIS_ORDERS)
847865

848866
def __nonzero__(self):

0 commit comments

Comments
 (0)