Skip to content
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

DOC: add alternative to docstring of deprecated Series.bool() method #55168

Merged
merged 5 commits into from
Sep 19, 2023
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
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
Loading