Q. Assume that required libraries (panda and numpy) are imported and dataframe df2 has been created as per questions.


Q. Predict the output of 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"}

Df = pd.DataFrame(my_di)

print(af)


and 

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)

 

Predict the output of following code fragment:


print ( df2["weight"])

print ( df2.weight['Tim' ] )


Answer =

Output:-

print(df2["weight"])
jiya      75
tim      123
rohan    239
Name: weight, dtype: int64   

print(df2.weight["tim"])
123

Post a Comment

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

Previous Post Next Post