A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.bool.html below:

pandas.DataFrame.bool — pandas 2.3.1 documentation

pandas.DataFrame.bool#
DataFrame.bool()[source]#

Return the bool of a single element Series or DataFrame.

Deprecated since version 2.1.0: 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 element is not boolean (integer values 0 and 1 will also raise an exception).

Returns:
bool

The value in the Series or DataFrame.

See also

Series.astype

Change the data type of a Series, including to boolean.

DataFrame.astype

Change the data type of a DataFrame, including to boolean.

numpy.bool_

NumPy boolean data type, used by pandas for boolean values.

Examples

The method will only work for single element objects with a boolean value:

>>> pd.Series([True]).bool()  
True
>>> pd.Series([False]).bool()  
False
>>> pd.DataFrame({'col': [True]}).bool()  
True
>>> pd.DataFrame({'col': [False]}).bool()  
False

This is an alternative method and will only work for single element objects with a boolean value:

>>> pd.Series([True]).item()  
True
>>> pd.Series([False]).item()  
False

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4