pandas.Panel.all¶
-
Panel.
all
(axis=0, bool_only=None, skipna=True, level=None, **kwargs)[source]¶ Return whether all elements are True, potentially over an axis.
Returns True if all elements within a series or along a Dataframe axis are non-zero, not-empty or not-False.
Parameters: axis : {0 or ‘index’, 1 or ‘columns’, None}, default 0
Indicate which axis or axes should be reduced.
- 0 / ‘index’ : reduce the index, return a Series whose index is the original column labels.
- 1 / ‘columns’ : reduce the columns, return a Series whose index is the original index.
- None : reduce all axes, return a scalar.
skipna : boolean, default True
Exclude NA/null values. If an entire row/column is NA, the result will be NA.
level : int or level name, default None
If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a DataFrame.
bool_only : boolean, default None
Include only boolean columns. If None, will attempt to use everything, then use only boolean data. Not implemented for Series.
**kwargs : any, default None
Additional keywords have no effect but might be accepted for compatibility with NumPy.
Returns: - all : DataFrame or Panel (if level specified)
See also
pandas.Series.all
- Return True if all elements are True
pandas.DataFrame.any
- Return True if one (or more) elements are True
Examples
Series
>>> pd.Series([True, True]).all() True >>> pd.Series([True, False]).all() False
DataFrames
Create a dataframe from a dictionary.
>>> df = pd.DataFrame({'col1': [True, True], 'col2': [True, False]}) >>> df col1 col2 0 True True 1 True False
Default behaviour checks if column-wise values all return True.
>>> df.all() col1 True col2 False dtype: bool
Specify
axis='columns'
to check if row-wise values all return True.>>> df.all(axis='columns') 0 True 1 False dtype: bool
Or
axis=None
for whether every value is True.>>> df.all(axis=None) False