Python pandas any all

pandas.Series.any#

Return whether any element is True, potentially over an axis.

Returns False unless there is at least one element within a series or along a Dataframe axis that is True or equivalent (e.g. non-zero or non-empty).

Parameters axis , default 0

Indicate which axis or axes should be reduced. For Series this parameter is unused and defaults to 0.

  • 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.

Include only boolean columns. If None, will attempt to use everything, then use only boolean data. Not implemented for Series.

skipna bool, default True

Exclude NA/null values. If the entire row/column is NA and skipna is True, then the result will be False, as for an empty row/column. If skipna is False, then NA are treated as True, because these are not equal to zero.

**kwargs any, default None

Additional keywords have no effect but might be accepted for compatibility with NumPy.

If level is specified, then, Series is returned; otherwise, scalar is returned.

Numpy version of this method.

Return whether any element is True.

Return whether all elements are True.

Return whether any element is True over requested axis.

Return whether all elements are True over requested axis.

For Series input, the output is a scalar indicating whether any element is True.

>>> pd.Series([False, False]).any() False >>> pd.Series([True, False]).any() True >>> pd.Series([], dtype="float64").any() False >>> pd.Series([np.nan]).any() False >>> pd.Series([np.nan]).any(skipna=False) True 

Whether each column contains at least one True element (the default).

>>> df = pd.DataFrame("A": [1, 2], "B": [0, 2], "C": [0, 0]>) >>> df A B C 0 1 0 0 1 2 2 0 
>>> df.any() A True B True C False dtype: bool 

Aggregating over the columns.

>>> df = pd.DataFrame("A": [True, False], "B": [1, 2]>) >>> df A B 0 True 1 1 False 2 
>>> df.any(axis='columns') 0 True 1 True dtype: bool 
>>> df = pd.DataFrame("A": [True, False], "B": [1, 0]>) >>> df A B 0 True 1 1 False 0 
>>> df.any(axis='columns') 0 True 1 False dtype: bool 

Aggregating over the entire DataFrame with axis=None .

any for an empty DataFrame is an empty Series.

>>> pd.DataFrame([]).any() Series([], dtype: bool) 

Источник

pandas.DataFrame.any#

Return whether any element is True, potentially over an axis.

Returns False unless there is at least one element within a series or along a Dataframe axis that is True or equivalent (e.g. non-zero or non-empty).

Parameters axis , default 0

Indicate which axis or axes should be reduced. For Series this parameter is unused and defaults to 0.

  • 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.

Include only boolean columns. If None, will attempt to use everything, then use only boolean data. Not implemented for Series.

skipna bool, default True

Exclude NA/null values. If the entire row/column is NA and skipna is True, then the result will be False, as for an empty row/column. If skipna is False, then NA are treated as True, because these are not equal to zero.

**kwargs any, default None

Additional keywords have no effect but might be accepted for compatibility with NumPy.

Returns Series or DataFrame

If level is specified, then, DataFrame is returned; otherwise, Series is returned.

Numpy version of this method.

Return whether any element is True.

Return whether all elements are True.

Return whether any element is True over requested axis.

Return whether all elements are True over requested axis.

For Series input, the output is a scalar indicating whether any element is True.

>>> pd.Series([False, False]).any() False >>> pd.Series([True, False]).any() True >>> pd.Series([], dtype="float64").any() False >>> pd.Series([np.nan]).any() False >>> pd.Series([np.nan]).any(skipna=False) True 

Whether each column contains at least one True element (the default).

>>> df = pd.DataFrame("A": [1, 2], "B": [0, 2], "C": [0, 0]>) >>> df A B C 0 1 0 0 1 2 2 0 
>>> df.any() A True B True C False dtype: bool 

Aggregating over the columns.

>>> df = pd.DataFrame("A": [True, False], "B": [1, 2]>) >>> df A B 0 True 1 1 False 2 
>>> df.any(axis='columns') 0 True 1 True dtype: bool 
>>> df = pd.DataFrame("A": [True, False], "B": [1, 0]>) >>> df A B 0 True 1 1 False 0 
>>> df.any(axis='columns') 0 True 1 False dtype: bool 

Aggregating over the entire DataFrame with axis=None .

any for an empty DataFrame is an empty Series.

>>> pd.DataFrame([]).any() Series([], dtype: bool) 

Источник

Читайте также:  Убрать туман css v34
Оцените статью