Q. Consider the same dictionary my_di, what will be the output produced by following code?

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"}

df2 = pd.DataFrame (my_di, index = my_di ["name"])

print (df2)


Answer =

Output:-

     name  age  weight  height  sibling gender
jiya       jiya  10    75            4.5                    1       M
tim        tim  15   123           5.0                    1       M
rohan     rohan  20   239        6.1               1    M

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post