KnowledgeBoat Logo
|

Informatics Practices

Create a dataframe of {‘A’ : [5, 6], ‘B’: [3, 0], 'C': [0, 0]} and display the result of all() and any() functions.

Python Data Handling

3 Likes

Answer

import pandas as pd
df = pd.DataFrame({'A': [5, 6], 'B': [3, 0], 'C': [0, 0]})
print(df)

print("\nResult of all() function:")
print(df.all())

print("\nResult of any() function:")
print(df.any())

Output

   A  B  C
0  5  3  0
1  6  0  0

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

3 Likes


Related Questions