Professional Documents
Culture Documents
ASSIGNMENT – 6
a. df=pd.DataFrame({"Name":Name,"Phy":Phy,"Chem":Chem})
b. d=("Name":Name,"Phy":Phy,"Chem":Chem) df=pd.DataFrame(d)
c. df=pd.DataFrame([Name,Phy,Chem],
columns=['Name',"Phy","Chem","Total"])
d. df=pd.DataFrame({Name:"Name", Phy :"Phy",Chem: "Chem"})
17. Assuming the given structure, which command will give us the given output:
b. df=pd.dataframe([stuname, term1,term2],
columns=[„stuName‟,”marks1”, “marks1”])
c. df=pd.DataFrame({stuname, term1,term2})
d. df=pd.dataframe({stuname, term1,term2})
c. 0 d. 0
b 50 a NaN
y 36 ab NaN
c 49 b NaN
ab 71 c NaN
d NaN
y NaN
34. Sudhanshu has written the following code to create a DataFrame with Boolean index :
import numpy as np
import pandas as pd
df=pd.DataFrame (data=[[5,6,7]], index=[true,false,true])
print(df)
While executing the code, she is getting an error, help her to rectify the code:
a. df=pd.DataFrame([True,False,True], data=[5,6,7])
Output:
Output:
Name Age
0 Sapna 16
1 Anmol 18
2 Rishul 16
3 Sameep 19
a. index b. columns
c. col d. heads
50. Complete the given Python code to get the required output as:
import pandas as pd
df1= pd.DataFrame(["First","Second"],columns=['Col'])
df2= pd.DataFrame(["Third","Fourth"],columns=['Col'])
df = pd.________([df2, df1], axis=0, ignore_index=True)
print(df)
Output:
Col
0 Third
1 Fourth
2 First
3 Second
a. loc b. iloc
c. concat d. merge