Skip to content

Doc: Clean obj.empty docs to describe Series/DataFrame #44430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2001,15 +2001,15 @@ def __contains__(self, key) -> bool_t:
@property
def empty(self) -> bool_t:
"""
Indicator whether DataFrame is empty.
Indicator whether Series/DataFrame is empty.

True if DataFrame is entirely empty (no items), meaning any of the
True if Series/DataFrame is entirely empty (no items), meaning any of the
axes are of length 0.

Returns
-------
bool
If DataFrame is empty, return True, if not return False.
If Series/DataFrame is empty, return True, if not return False.

See Also
--------
Expand All @@ -2019,7 +2019,7 @@ def empty(self) -> bool_t:

Notes
-----
If DataFrame contains only NaNs, it is still not considered empty. See
If Series/DataFrame contains only NaNs, it is still not considered empty. See
the example below.

Examples
Expand All @@ -2045,6 +2045,16 @@ def empty(self) -> bool_t:
False
>>> df.dropna().empty
True

>>> ser_empty = pd.Series({'A' : []})
>>> ser_empty
A []
dtype: object
>>> ser_empty.empty
False
>>> ser_empty = pd.Series()
>>> ser_empty.empty
True
"""
return any(len(self._get_axis(a)) == 0 for a in self._AXIS_ORDERS)

Expand Down