Skip to content

Commit b6c08a9

Browse files
kgmuzungumroeschke
authored andcommitted
DOC: add alternative to docstring of deprecated Series.bool() method (pandas-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]>
1 parent 45cf653 commit b6c08a9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pandas/core/generic.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,8 @@ def bool(self) -> bool_t:
15261526
15271527
.. deprecated:: 2.1.0
15281528
1529-
bool is deprecated and will be removed in future version of pandas
1529+
bool is deprecated and will be removed in future version of pandas.
1530+
For ``Series`` use ``pandas.Series.item``.
15301531
15311532
This must be a boolean scalar value, either True or False. It will raise a
15321533
ValueError if the Series or DataFrame does not have exactly 1 element, or that
@@ -1556,6 +1557,14 @@ def bool(self) -> bool_t:
15561557
True
15571558
>>> pd.DataFrame({'col': [False]}).bool() # doctest: +SKIP
15581559
False
1560+
1561+
This is an alternative method and will only work
1562+
for single element objects with a boolean value:
1563+
1564+
>>> pd.Series([True]).item() # doctest: +SKIP
1565+
True
1566+
>>> pd.Series([False]).item() # doctest: +SKIP
1567+
False
15591568
"""
15601569

15611570
warnings.warn(

0 commit comments

Comments
 (0)