Page 122 - IPP-12-2025
P. 122
13. How are dataframes related to series?
Ans. Dataframe and series both are data structures in Pandas library. The individual columns of a dataframe can
be considered as a series object.
14. What do you understand by the size of (i) series, (ii) dataframe?
Ans. Size attribute gives the number of elements present in series or dataframes.
15. Which is the standard data missing marker used in Pandas?
Ans. NaN
16. How can we fill missing values in dataframe?
Ans. For filling missing values, we can use fillna() method. For example,
df = df1.fillna(0)
17. Which attribute is used to add a new row and change the data values of a row in a dataframe ‘df1’?
Ans. df1.loc[ ] attribute
18. What type of error is returned when the length of index and the length of data in Series() function is not
same?
Ans. ValueError
19. Which parameter is used to specify row or column in rename() function of dataframe?
Ans. index
20. What will the following statement do?
Df1 = df.drop(['Name','Class','Rollno'],axis = 1)#Df1 is a dataframe object
Ans. It will delete three columns having labels ‘Name’, ‘Class’ and ‘Rollno’ from the dataframe df.
21. Does drop() function delete the column from a dataframe permanently? If not, how can we do that?
Ans. No, drop() function does not delete the content until and unless we use inplace=True argument as it makes
permanent changes.
22. Explain Reindexing in Pandas.
Ans. Reindexing means to conform dataframe to a new index placing NA/NaN in locations having no value in
the previous index. It changes the row labels and column labels of a dataframe.
23. What difference do we see in deleting with del and pop methods?
Ans. del method does not display the contents of the column deleted whereas pop() method deletes an existing
column as well as displays the contents of the deleted column.
24. Which object in Pandas cannot grow in size?
Ans. Series
25. Which attribute is used to check if the series object contains NaN values?
Ans. hasnans
26. Name the function used to display first 5 and last 5 rows from a series or dataframe.
Ans. head() and tail() functions.
27. Given the following dictionaries:
dict_exam={"Exam":"AISSCE", "Year":2023}
dict_result={"Total":500, "Pass_Marks":165}
Give the statement to merge the contents of both dictionaries.
Ans. dict_exam.update(dict_result)
28. Write a command to store data of dataframe mdf into a CSV file Mydata.csv, with separate character as
"@".
Ans. mdf.to_csv("Mydata.csv", sep="@")
29. How did the name ‘Pandas’ originate?
Ans. The name ‘Pandas’ is derived from ‘Panel Data’.
30. What is the importance of Data Visualization? Name the various types of charts supported by Pandas.
Ans. Data Visualization is the graphical or visual representation of information and data using visual
elements like charts, graphs, maps, etc. They are often used to ease understanding of large quantities of
data and the relationships between parts of the data. Charts can usually be read more quickly than raw
data. The various types of charts supported by Pandas are line, bar, histograms, pie, box, etc.
V.2 Informatics Practices with Python–XII