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
- C
- 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
- 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'
- 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
- df.rename(columns-{"highway - mpe"': 'highway-L/100km'}, inplace-True)
- rename(df,columns={""highway-mpg"': 'highway-L/100km'})
_____________________________________________________________
Data Analysis with Python
_____________________________________________________________
1 Comments
Nice work dude..
ReplyDelete