0
0
Data Analysis Pythondata~20 mins

Identifying missing values (isnull, isna) in Data Analysis Python - 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 isnull() on a DataFrame
What is the output of the following code snippet?
Data Analysis Python
import pandas as pd
import numpy as np
df = pd.DataFrame({
    'A': [1, np.nan, 3],
    'B': [np.nan, 2, 3]
})
result = df.isnull()
print(result)
A
       A      B
0  False   True
1   True  False
2  False  False
B
       A      B
0  False   True
1   True   True
2  False  False
C
       A      B
0  False  False
1   True   True
2  False  False
D
       A      B
0   True  False
1  False   True
2  False  False
Attempts:
2 left
💡 Hint
Remember that isnull() returns True where values are missing (NaN).
data_output
intermediate
2:00remaining
Counting missing values with isna()
What is the output of this code that counts missing values per column?
Data Analysis Python
import pandas as pd
import numpy as np
df = pd.DataFrame({
    'X': [np.nan, 1, 2, np.nan],
    'Y': [3, 4, np.nan, 6]
})
missing_counts = df.isna().sum()
print(missing_counts)
A
X    2
Y    1
dtype: int64
B
X    1
Y    2
dtype: int64
C
X    0
Y    0
dtype: int64
D
X    2
Y    2
dtype: int64
Attempts:
2 left
💡 Hint
Count how many NaN values appear in each column.
🔧 Debug
advanced
2:00remaining
Identify the error in using isnull() on a list
What error will this code raise?
Data Analysis Python
import pandas as pd
values = [1, None, 3]
result = values.isnull()
print(result)
ANo error, prints [False, True, False]
BTypeError: isnull() missing 1 required positional argument
CAttributeError: 'list' object has no attribute 'isnull'
DValueError: Cannot convert list to DataFrame
Attempts:
2 left
💡 Hint
Check if the list type supports isnull() method.
🚀 Application
advanced
2:00remaining
Filter rows with missing values using isna()
Which code snippet correctly filters rows with any missing values in DataFrame df?
Data Analysis Python
import pandas as pd
import numpy as np
df = pd.DataFrame({
    'A': [1, np.nan, 3],
    'B': [4, 5, np.nan]
})
Adf[df.isna().all(axis=0)]
Bdf[df.isna().any(axis=1)]
Cdf[df.isna().any(axis=0)]
Ddf[df.isna().all(axis=1)]
Attempts:
2 left
💡 Hint
Use isna() with any() along rows to find rows with missing values.
🧠 Conceptual
expert
2:00remaining
Difference between isnull() and isna() in pandas
Which statement best describes the difference between pandas isnull() and isna() methods?
Aisnull() detects missing values, isna() detects empty strings.
Bisnull() detects only None values, while isna() detects only NaN values.
Cisnull() works only on DataFrames, isna() works only on Series.
DThey are exactly the same; both detect missing values identically.
Attempts:
2 left
💡 Hint
Check pandas documentation for isnull() and isna() methods.