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
1 Like
Related Questions
Create a dataframe of D1 and D2;
D1 = {‘Rollno’ : [1001, 1004, 1005, 1008, 1009], ‘Name’: [‘Sarika’, ‘Abhay’, ‘Mohit’, ‘Ruby’, ‘Govind’ ]}
D2 = {‘Rollno’ : [1002, 1003, 1004, 1005, 1006], ‘Name’:[‘Seema’,‘Jia’,‘Shweta’, ‘Sonia’, ‘Nishant’]}(a) Concatenate row-wise.
(b) Concatenate column-wise.
Create a dataframe of {‘A’ : [ ]} and display whether it is empty or not.
Create a dataframe of {‘A’ : [True, True], ‘B’: [True, False], ‘C’: [False, False]} and display the result of all() and any().
What is the use of statement: inplace=True?