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”
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
Practice Quiz: Turning categorical variables into quantitative variables in Python
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?
- 3
