0
0
Pandasdata~20 mins

Detecting missing values with isna() in Pandas - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Missing Values Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of isna() on a DataFrame column
What is the output of the following code snippet?
Pandas
import pandas as pd

df = pd.DataFrame({'A': [1, None, 3], 'B': [None, 2, 3]})
result = df['A'].isna()
print(result)
A
0     True
1    False
2     True
Name: A, dtype: bool
B
0    False
1     True
2    False
Name: A, dtype: bool
C
0    False
1    False
2    False
Name: A, dtype: bool
D
0     True
1     True
2     True
Name: A, dtype: bool
Attempts:
2 left
💡 Hint
Check which values in column 'A' are missing (None).
data_output
intermediate
2:00remaining
Count missing values in DataFrame
What is the output of this code that counts missing values in each column?
Pandas
import pandas as pd

df = pd.DataFrame({'X': [1, 2, None, 4], 'Y': [None, None, 3, 4]})
missing_counts = df.isna().sum()
print(missing_counts)
A
X    0
Y    0
dtype: int64
B
X    2
Y    1
dtype: int64
C
X    1
Y    2
dtype: int64
D
X    1
Y    1
dtype: int64
Attempts:
2 left
💡 Hint
Count how many None values are in each column.
visualization
advanced
3:00remaining
Visualizing missing values with isna()
Which option correctly creates a heatmap showing missing values in the DataFrame?
Pandas
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

df = pd.DataFrame({'A': [1, None, 3], 'B': [None, 2, None], 'C': [1, 2, 3]})
sns.heatmap(____, cbar=False)
plt.show()
Adf.isna().sum()
Bdf.notna()
Cdf
Ddf.isna()
Attempts:
2 left
💡 Hint
Heatmap needs a boolean DataFrame showing missing values.
🔧 Debug
advanced
2:00remaining
Identify the error in missing value detection
What error will this code raise?
Pandas
import pandas as pd

df = pd.DataFrame({'A': [1, 2, 3]})
result = df.isna('A')
print(result)
ATypeError: isna() takes no arguments (1 given)
BKeyError: 'A'
CAttributeError: 'DataFrame' object has no attribute 'isna'
DNo error, prints a DataFrame of False values
Attempts:
2 left
💡 Hint
Check the method signature of isna().
🚀 Application
expert
3:00remaining
Filter rows with missing values in multiple columns
Given the DataFrame below, which code correctly filters rows where either column 'X' or 'Y' has missing values?
Pandas
import pandas as pd

df = pd.DataFrame({'X': [1, None, 3, None], 'Y': [None, 2, None, 4]})
Adf[df['X'].isna() | df['Y'].isna()]
Bdf[df.isna('X') | df.isna('Y')]
Cdf[df.isna()['X'] & df.isna()['Y']]
Ddf[df['X'].notna() | df['Y'].notna()]
Attempts:
2 left
💡 Hint
Use isna() on each column separately and combine with | for OR.