Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check for missing values in the DataFrame.
ML Python
missing = df.isnull().[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
2fill in blank
mediumComplete the code to fill missing values with the mean of the column.
ML Python
df['age'] = df['age'].[1](df['age'].mean())
Drag options to blanks, or click blank then click option'
Attempts:
3 left
3fill in blank
hardFix the error in the code to drop rows with any missing values.
ML Python
cleaned_df = df.[1](axis=0, how='any')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
4fill in blank
hardFill both blanks to create a new DataFrame with missing values replaced by the median.
ML Python
df_clean = df.[1](df.[2]())
Drag options to blanks, or click blank then click option'
Attempts:
3 left
5fill in blank
hardFill all three blanks to create a dictionary of column means for filling missing values.
ML Python
fill_values = {col: df[col].[1]() for col in df.columns if df[col].[2]().any()}
df_filled = df.[3](fill_values) Drag options to blanks, or click blank then click option'
Attempts:
3 left