Skip to content

Commit

Permalink
DOC: add alternative to docstring of deprecated Series.bool() method (p…
Browse files Browse the repository at this point in the history
…andas-dev#55168)

* Fix for series boolean documentation

* one blank line removed. docstring error

* Update pandas/core/generic.py

fixing text formating

Co-authored-by: Matthew Roeschke <[email protected]>

* Update pandas/core/generic.py

text formatting fixed

Co-authored-by: Matthew Roeschke <[email protected]>

---------

Co-authored-by: Matthew Roeschke <[email protected]>
  • Loading branch information
2 people authored and hedeershowk committed Sep 20, 2023
1 parent 45cf653 commit b6c08a9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1556,6 +1557,14 @@ def bool(self) -> bool_t:
True
>>> pd.DataFrame({'col': [False]}).bool() # doctest: +SKIP
False
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(
Expand Down

0 comments on commit b6c08a9

Please sign in to comment.