21 August 2020
Code
Note: Example below uses Pandas Series. However, it may be used with other objects such as a list, array etc.
# Create a Series
import pandas as pd
x =pd.Series(['jungle', 'tree', 'zoo', 'panda'])
# Check if element exists in a Series
x = (x=='panda')
print(x)
0 False
1 False
2 False
3 True
dtype: bool
.
# Returns 'True' if atleast one value is True
any(x)
True
.
# Returns 'True' only if all values are True
all(x)
False
Any errors in code above?
Please send a message.