From 9cdc80d264e2938875ec856cb921feed2641ddbc Mon Sep 17 00:00:00 2001 From: kgmuzungu Date: Sat, 16 Sep 2023 15:08:06 +0000 Subject: [PATCH 1/4] Fix for series boolean documentation --- pandas/core/generic.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 5c303e2a73bd7..65d5cfb2a558c 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -1526,7 +1526,8 @@ def bool(self) -> bool_t: .. deprecated:: 2.1.0 - bool is deprecated and will be removed in future version of pandas + bool is deprecated and will be removed in future version of pandas. + For series use pandas.Series.item. This must be a boolean scalar value, either True or False. It will raise a ValueError if the Series or DataFrame does not have exactly 1 element, or that @@ -1556,6 +1557,17 @@ def bool(self) -> bool_t: True >>> pd.DataFrame({'col': [False]}).bool() # doctest: +SKIP False + + + Alternative + -------- + This is an alternative method and will only work + for single element objects with a boolean value: + + >>> pd.Series([True]).item() # doctest: +SKIP + True + >>> pd.Series([False]).item() # doctest: +SKIP + False """ warnings.warn( From 78b2a5109758470c97870397cff242c3bde69ef7 Mon Sep 17 00:00:00 2001 From: kgmuzungu Date: Sun, 17 Sep 2023 17:00:56 +0200 Subject: [PATCH 2/4] one blank line removed. docstring error --- pandas/core/generic.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 65d5cfb2a558c..34ae2ba2c30b8 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -1558,7 +1558,6 @@ def bool(self) -> bool_t: >>> pd.DataFrame({'col': [False]}).bool() # doctest: +SKIP False - Alternative -------- This is an alternative method and will only work From a9753c79eaeec289e083d6b374bc2fdf46727105 Mon Sep 17 00:00:00 2001 From: kgmuzungu Date: Mon, 18 Sep 2023 21:27:02 +0200 Subject: [PATCH 3/4] Update pandas/core/generic.py fixing text formating Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index de2ad9d11d6be..01340d2252e6a 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -1527,7 +1527,7 @@ def bool(self) -> bool_t: .. deprecated:: 2.1.0 bool is deprecated and will be removed in future version of pandas. - For series use pandas.Series.item. + For ``Series`` use ``pandas.Series.item``. This must be a boolean scalar value, either True or False. It will raise a ValueError if the Series or DataFrame does not have exactly 1 element, or that From d881cf5a19cfd2f300382386743e5bb66e9dd5e1 Mon Sep 17 00:00:00 2001 From: kgmuzungu Date: Mon, 18 Sep 2023 21:27:32 +0200 Subject: [PATCH 4/4] Update pandas/core/generic.py text formatting fixed Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- pandas/core/generic.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 01340d2252e6a..b0063ca659a38 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -1558,8 +1558,6 @@ def bool(self) -> bool_t: >>> pd.DataFrame({'col': [False]}).bool() # doctest: +SKIP False - Alternative - -------- This is an alternative method and will only work for single element objects with a boolean value: