data analysis with python coursera week 2 quiz answers

Practice Quiz: Dealing with Missing Values in Python

1. How would you access the column ”body-style" from the dataframe df?

  • df[ “body-style”]
  • df==”bodystyle”

2. What is the correct symbol for missing data?

  • nan
  • no-data

Practice Quiz: Data Formatting in Python

3. How would you cast each element in the column "price" to an integer?

  • df[“price”] = int(df[“price”])
  • df[“price”] = df[“price”].astype(“int”)

Practice Quiz: Data Normalization in Python

4. What is the maximum value for feature scaling?

Practice Quiz: Turning categorical variables into quantitative variables in Python

5. Consider the column 'diesel'; what should the value for Car B be?

  • 0
  • 1

Graded Quiz: Data Wrangling

6. What task do the following lines of code perform z

df['bore'].replace(np.nan, avg, inplace= True)

  • calculate the mean value for the ‘bore’ column and replace all the NaN values of that column by the mean value
  • nothing; because the parameter inplace is not set to true
  • ‘horsepower’

7. How would you rename column name from "highway-mpg" to "highway-L/100km"?

  • df.rename(columns={‘”highway-mpg”‘:’highway-L/100km’}, inplace=True)
  • rename(df,columns={‘”highway-mpg”‘:’highway-L/100km’})

8. How would you cast the column "losses" to an integer?

  • df[[“losses”]]=df[[“losses”]].astype(“int”)
  • df[[“losses”]].astype(“int”)

9. The following code is an example of:


  • simple feature scaling
  • min-max scaling
  • z-score

10. Consider the two columns 'horsepower', and 'horsepower-binned'; from the dataframe df; how many categories are there in the 'horsepower-binned' column?

Leave a Reply