CBSE Class 12 Informatics Practices Question 133 of 167

Python Pandas — I — Question 23

Back to all questions
23
Question

Question 17

Predict the output of following code (it uses below given dictionary my_di).

my_di = {"name" : ["Jiya", "Tim", "Rohan"],
         "age" : np.array([10, 15, 20]),
         "weight" : (75, 123, 239),
         "height" : [4.5, 5, 6.1],
         "siblings" : 1,
         "gender" : "M"}
df = pd.DataFrame(my_di)
print(df)
Answer
Output
    name  age  weight  height  siblings gender
0   Jiya   10      75     4.5         1      M
1    Tim   15     123     5.0         1      M
2  Rohan   20     239     6.1         1      M
Explanation

The given code creates a dictionary my_di. Then, a DataFrame df is created using the pd.DataFrame() constructor and passing the my_di dictionary. The print() function is used to display the DataFrame.