0
0
Pandasdata~10 mins

Dropping missing values with dropna() 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 drop rows with any missing values from the DataFrame.

Pandas
cleaned_df = df.[1]()
Drag options to blanks, or click blank then click option'
Afillna
Bisnull
Cdropna
Dreplace
Attempts:
3 left
💡 Hint
Common Mistakes
Using fillna() instead of dropna()
Using isnull() which only checks for missing values
Using replace() which replaces values but does not drop rows
2fill in blank
medium

Complete the code to drop columns with any missing values from the DataFrame.

Pandas
cleaned_df = df.dropna(axis=[1])
Drag options to blanks, or click blank then click option'
A-1
B2
C0
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using axis=0 which drops rows instead of columns
Using axis=2 or -1 which are invalid for dropna()
3fill in blank
hard

Fix the error in the code to drop rows only if all values are missing.

Pandas
cleaned_df = df.dropna(how='[1]')
Drag options to blanks, or click blank then click option'
Aany
Ball
Cnone
Dsome
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'any' which drops rows with any missing value
Using invalid strings like 'none' or 'some'
4fill in blank
hard

Fill both blanks to drop rows with less than 3 non-missing values.

Pandas
cleaned_df = df.dropna(thresh=[1], axis=[2])
Drag options to blanks, or click blank then click option'
A3
B2
C1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using thresh less than 3 which drops too few rows
Using axis=1 which drops columns instead of rows
5fill in blank
hard

Fill all three blanks to drop columns with less than 2 non-missing values and reset the index.

Pandas
cleaned_df = df.dropna(thresh=[1], axis=[2]).[3](drop=True)
Drag options to blanks, or click blank then click option'
A1
B2
Dreset_index
Attempts:
3 left
💡 Hint
Common Mistakes
Using axis=0 which drops rows instead of columns
Not resetting the index after dropping rows or columns
Using incorrect thresh value