pandas 1.4.2

ParametersReturns
any(self, *, skipna: 'bool' = True, **kwargs)

Returns False unless there is at least one element that is truthy. By default, NAs are skipped. If skipna=False is specified and missing values are present, similar Kleene logic <boolean.kleene> is used as for logical operations.

versionchanged

Parameters

skipna : bool, default True

Exclude NA values. If the entire array is NA and :None:None:`skipna` is True, then the result will be False, as for an empty array. If :None:None:`skipna` is False, the result will still be True if there is at least one element that is truthy, otherwise NA will be returned if there are NA's present.

**kwargs : any, default None

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

Returns

bool or : attr:`pandas.NA`

Return whether any element is truthy.

See Also

BaseMaskedArray.all

Return whether all elements are truthy.

numpy.any

Numpy version of this method.

Examples

The result indicates whether any element is truthy (and by default skips NAs):

This example is valid syntax, but we were not able to check execution
>>> pd.array([True, False, True]).any()
True
This example is valid syntax, but we were not able to check execution
>>> pd.array([True, False, pd.NA]).any()
True
This example is valid syntax, but we were not able to check execution
>>> pd.array([False, False, pd.NA]).any()
False
This example is valid syntax, but we were not able to check execution
>>> pd.array([], dtype="boolean").any()
False
This example is valid syntax, but we were not able to check execution
>>> pd.array([pd.NA], dtype="boolean").any()
False
This example is valid syntax, but we were not able to check execution
>>> pd.array([pd.NA], dtype="Float64").any()
False

With skipna=False , the result can be NA if this is logically required (whether pd.NA is True or False influences the result):

This example is valid syntax, but we were not able to check execution
>>> pd.array([True, False, pd.NA]).any(skipna=False)
True
This example is valid syntax, but we were not able to check execution
>>> pd.array([1, 0, pd.NA]).any(skipna=False)
True
This example is valid syntax, but we were not able to check execution
>>> pd.array([False, False, pd.NA]).any(skipna=False)
<NA>
This example is valid syntax, but we were not able to check execution
>>> pd.array([0, 0, pd.NA]).any(skipna=False)
<NA>
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/arrays/masked.py#880
type: <class 'function'>
Commit: