Challenge - 5 Problems
Missing Values Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of dropna() on a Series with missing values
What is the output of this code?
import pandas as pd s = pd.Series([1, None, 3, None, 5]) result = s.dropna() print(result)
Data Analysis Python
import pandas as pd s = pd.Series([1, None, 3, None, 5]) result = s.dropna() print(result)
Attempts:
2 left
💡 Hint
dropna() removes all missing (NaN) values from the Series.
✗ Incorrect
The dropna() method removes all missing values (None or NaN) from the Series and returns a new Series with only the non-missing values and their original indices.
❓ data_output
intermediate1:30remaining
Count of missing values in a Series
Given this Series, what is the output of s.isna().sum()?
Data Analysis Python
import pandas as pd s = pd.Series([10, None, 20, None, 30, None]) print(s.isna().sum())
Attempts:
2 left
💡 Hint
isna() returns True for missing values, sum counts them.
✗ Incorrect
The Series has three None values which are treated as missing (NaN). isna() marks them True, sum counts how many True values exist.
🔧 Debug
advanced2:00remaining
Identify the error in filling missing values
What error will this code raise?
import pandas as pd s = pd.Series([1, None, 3, None, 5]) result = s.fillna(method='backward') print(result)
Data Analysis Python
import pandas as pd s = pd.Series([1, None, 3, None, 5]) result = s.fillna(method='backward') print(result)
Attempts:
2 left
💡 Hint
Check the valid method names for fillna() in pandas.
✗ Incorrect
The fillna() method accepts 'ffill' or 'bfill' as method values. 'backward' is not valid and causes a ValueError.
🚀 Application
advanced2:30remaining
Replacing missing values with mean
You have this Series with missing values. Which option correctly replaces missing values with the mean of the non-missing values?
import pandas as pd s = pd.Series([2, None, 4, None, 6]) mean_val = s.mean()
Data Analysis Python
import pandas as pd s = pd.Series([2, None, 4, None, 6]) mean_val = s.mean()
Attempts:
2 left
💡 Hint
fillna() can replace missing values with a scalar value; inplace modifies the original Series.
✗ Incorrect
Option A correctly uses fillna() with the mean value and inplace=True to update s. Option A returns a new Series but does not update s, so print(s) shows original with missing values.
🧠 Conceptual
expert1:30remaining
Effect of dropna() on Series index
After applying dropna() on a Series with missing values, what happens to the index of the resulting Series?
Attempts:
2 left
💡 Hint
Think about whether dropna() changes the index or just removes rows.
✗ Incorrect
dropna() removes rows with missing values but keeps the original index labels of the remaining entries unchanged.