Home »
Python »
Python Pandas MCQs
What will be output of following code –? Pandas Question 5
16. What will be output of following code –?
import pandas as pd
data = [['Anuj',21],['Rama',25],['Kapil',22]]
df = pd.DataFrame(data,columns=['Name','Age'])
print (df)
-
Name Age
0 Anuj 21
1 Rama 25
2 Kapil 22
-
Name Age
0 Anuj 21
1 Kapil 22
2 Rama 25
-
Name Age
0 Kapil 22
1 Rama 25
2 Anuj 21
-
Name Age
0 Rama 25
1 Anuj 21
2 Kapil 22
Answer: A)
Name Age
0 Anuj 21
1 Rama 25
2 Kapil 22
Explanation:
In the above code, the data is including name and age of the candidates like [['Anuj',21],['Rama',25],['Kapil',22]]. And in the next line of the code df = pd.DataFrame(data,columns=['Name','Age']), name and age is strong in df and when we print(df), this will print the name and age of the candidates on screen.