0
0
Pandasdata~10 mins

Filling missing values with fillna() in Pandas - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to fill missing values in the DataFrame column 'Age' with 30.

Pandas
df['Age'] = df['Age'].[1](30)
Drag options to blanks, or click blank then click option'
Afillna
Bisnull
Cdropna
Dreplace
Attempts:
3 left
💡 Hint
Common Mistakes
Using replace() instead of fillna() does not specifically target missing values.
Using dropna() removes rows with missing values instead of filling them.
2fill in blank
medium

Complete the code to fill missing values in the entire DataFrame with the value 0.

Pandas
df = df.[1](0)
Drag options to blanks, or click blank then click option'
Adropna
Bfillna
Creplace
Disnull
Attempts:
3 left
💡 Hint
Common Mistakes
Using dropna() removes rows with missing values instead of filling them.
Using replace() does not specifically target missing values.
3fill in blank
hard

Fix the error in the code to fill missing values in column 'Score' with the mean of that column.

Pandas
df['Score'] = df['Score'].[1](df['Score'].mean())
Drag options to blanks, or click blank then click option'
Afillna
Bisnull
Cdropna
Dreplace
Attempts:
3 left
💡 Hint
Common Mistakes
Using replace() does not fill missing values correctly.
Using dropna() removes rows instead of filling missing values.
4fill in blank
hard

Fill both blanks to create a dictionary that fills missing values in 'Height' with 170.

Pandas
df = df.fillna([1]: [2])
Drag options to blanks, or click blank then click option'
A'Height'
B170
C65
D'Weight'
Attempts:
3 left
💡 Hint
Common Mistakes
Using numbers as keys instead of column names.
Swapping keys and values.
5fill in blank
hard

Fill all three blanks to create a dictionary that fills missing values in 'Height' with 170 and 'Weight' with 65, then apply it with fillna().

Pandas
fill_values = [1]: [2], [3]: 65}
df = df.fillna(fill_values)
Drag options to blanks, or click blank then click option'
A'Height'
B170
C'Weight'
D65
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting column names.
Using strings for numeric fill values.