Data Analysis with Python Week 2 Quiz Answer

Data Analysis with Python Week 2 Quiz Answer

Data Analysis with Python 

Week 2 Quiz Answer



Practice Quiz 1

Dealing with Missing Values in Python


Q1) How would you access the column "body-style" from the dataframe df?


  • dff {"body-style"]
  • df =="bodystyle"



Q2) How would you replace the missing values in the column "normalized-losses" with the mean of that column?


  • mean = df ["normalized-losses"].mean() 
  • df["normalized-losses").replace(np.nan, mean)


  • df.dropna(subset=["price"], axis-8, inplace - True)



Q3) What is the correct symbol for missing data?


  • nan
  • no-data




Practice Quiz 2

Data Formatting in Python


Q1) How would you multiply each element in the column df["a"] by 2 and assign it back to the column df["a"?


  • 2*df["a")
  • df["a")=2*df{"a")
  • df["a"]=df["a"]-1



Q2) How would you rename the column "city_mpg" to "city-L/100km"?


  • df.rename(columns-{"city_mpg": "city-L/100km"), inplace-True)
  • df.rename(columns-{"city_mpg": "city-L/100km"})





Practice Quiz 3

Data Normalization in Python



Q1) Which of the following is the correct formula for 2-score or data standardization?



  •  C



Q2) Consider the column "length"; select the correct code for z-score or standard score.

  • df["length"] = (df["length"]-df["length"].min()/
  • (df["length"].max()-df["length"].min())
  • df ["length"] = (df["length"]-df["length"].mean())/df["length"].std()





Practice Quiz 4

Data Wrangling



Q1) What task does the following line of code perform?

df['peak-rpn'].mean()

  • calculate the mean of the column "peak-rpm
  • calculate the mean of the dataframe df
  • replace missing data with the mean value from the column 'peak-rpm'




Q2) What task do the following lines of code perform?

avg-df('bare').mean(axis-a) 
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




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

  • df.rename(columns-{"highway - mpe"': 'highway-L/100km'}, inplace-True)
  • rename(df,columns={""highway-mpg"': 'highway-L/100km'})







_____________________________________________________________


Data Analysis with Python




_____________________________________________________________







Post a Comment

1 Comments