KnowledgeBoat Logo
|

Informatics Practices

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)

Python Pandas

2 Likes

Answer

    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

Working

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.

Answered By

3 Likes


Related Questions