sa 11 ip chapter 11

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

df2[“College”] = pd.Series([“IIT”], index=[“Rohan”]) print(df2) # Solution import pandas as pd, numpy as np 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”]) df2[“College”] = pd.Series([“IIT”], index=[“Rohan”]) # Adds a column ‘College’ with all values NaN except […]

8. Assume that required libraries (pandas and numpy) are imported and dataframe df2 has been created as per questions 4 and 5 above. Predict the output produced by following code fragment : Read More »

6. Assume that required libraries (panda and numpy) are imported and dataframe df2 has been created as per questions 4 and 5 above. Predict the output of following code fragment :

print(df2[“weight”]) print(df2.weight[’Tim’]) # Solution import pandas as pd, numpy as np 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[“weight”] ) print(df2.weight[‘Tim’]) # Output Jiya 75 Tim 123 Rohan 239 Name: weight, dtype: int64 123

6. Assume that required libraries (panda and numpy) are imported and dataframe df2 has been created as per questions 4 and 5 above. Predict the output of following code fragment : Read More »