From f2d133cca904b44c7989be7735b01523d6d55706 Mon Sep 17 00:00:00 2001 From: phofl Date: Sat, 13 Nov 2021 20:37:02 +0100 Subject: [PATCH] Doc: Clean obj.empty docs to describe Series/DataFrame --- pandas/core/generic.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 23608cf0192df..30e057cac968f 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -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 -------- @@ -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 @@ -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)