Python For Data Science July 2024W3
Python For Data Science July 2024W3
Python For Data Science July 2024W3
Week 3 assignment
1. Which of the following is the correct approach to fill missing values in case of categorical
variable? [1 mark]
(a) Mean
(b) median
(c) Mode
(d) None of the above
Answer: c
Assume a pandas dataframe df cars which when printed is as shown below. Based on
this information, answer questions 2 and 3.
2. Of the following set of statements, which of them can be used to extract the column
Type as a separate dataframe? [1 mark]
(a) df cars[[‘Type’]]
(b) df cars.iloc[[:, 1]
(c) df cars.loc[:, [‘Type’]]
(d) None of the above
Answer: a, c
1
3. The method df cars.describe() will give description of which of the following column?
[1 mark]
Answer: c
(a) pd.merge()
(b) pd.concat()
(c) join()
(d) None of the above
Answer: b
(a) Pandas
(b) Matplotlib
(c) NumPy
(d) All of the above
Answer: d
Read the ‘flavors of cocoa.csv’ file as a dataframe ‘df cocoa’ and answer questions 6-9.
The description of features/variables is given below:
Variable Description
ID Serial no.
Company Name of a manufacturing company
Bean Origin Place of origin of cocoa bean
Review Data Year in which chocolates were rated
Cocoa percent Percentage of cocoa in chocolate
Company Location Location of a manufacturing company
Rating Rating of chocolates
(a) ID
2
(b) Company
(c) Review Date
(d) Rating
Answer: c
(a) U.K.
(b) U.S.A.
(c) Canada
(d) France
Answer: b
8. After checking the data summary, which feature requires a data conversion considering
the data values held? [1 mark]
(a) Rating
(b) Review date
(c) Company
(d) Bean origin
Answer: b
(a) 1.00
(b) 5.00
(c) 3.18
(d) 4.00
Answer: b
3
(a) [bool, int, float, float, str]
(b) [str, int, float, float, str]
(c) [bool, int, float, int, str]
(d) [bool, int, int, float, str]
Answer: a