Series.any() function in pandasThe Series.any() function in pandas checks whether any element in a given Series is True, across the specified axis.
Series.any(axis=0, bool_only=None, skipna=True, level=None)
axis: This represents the axis in which the operation is to be performed.
bool_only: This includes only boolean values.
skipna: This parameter is used to skip NaN values. The default is True.
level: The default is None. It represents the level to be broadcasted (in the case of multilevel).
The following code will demonstrate how to use the Series.any() function in pandas.
import pandas as pdimport numpy as np# create Seriesnum_series = pd.Series([np.nan, 1, 0, 4,np.nan, 2])# using Series.any()print(num_series.any())
Lines 1–2: We import the libraries pandas and numpy.
Line 4: We create the num_series series.
Lines 7: We check for any true value in the Series using the any() function.