KnowledgeBoat Logo
|

Informatics Practices

Assume that required libraries (panda and numpy) are imported and dataframe df2 has been created as per questions 17 and 18 above. Predict the output produced by following code fragment :

Python Pandas

2 Likes

Answer

        name  age  weight  height  siblings gender College
Jiya    Jiya   10      75     4.5         1      M     NaN
Tim      Tim   15     123     5.0         1      M     NaN
Rohan  Rohan   20     239     6.1         1      M     IIT

Working

The code snippet uses the pandas and numpy libraries in Python to create a DataFrame named df2 from a dictionary my_di. The DataFrame is indexed by names, and a new column "College" is added with "IIT" as the value only for the index named "Rohan."

Answered By

1 Like


Related Questions