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

avg=df['bore'].mean(axis=0)
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:

(df["length"]-df["length"].mean())/df["length"].std()

  • 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