Informatics Practices
Create a dataframe of {‘A’ : [True, True], ‘B’: [True, False], ‘C’: [False, False]} and display the result of all() and any().
Python Data Handling
2 Likes
Answer
import pandas as pd
df = pd.DataFrame({'A': [True, True], 'B': [True, False], 'C': [False, False]})
print(df)
print("\nResult of all() function:")
print(df.all())
print("\nResult of any() function:")
print(df.any())Output
A B C
0 True True False
1 True False False
Result of all() function:
A True
B False
C False
dtype: bool
Result of any() function:
A True
B True
C False
dtype: bool
Answered By
1 Like