Challenge - 5 Problems
Series Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1:30remaining
Output of Series with custom index
What is the output of this code snippet?
Pandas
import pandas as pd s = pd.Series([10, 20, 30], index=['a', 'b', 'c']) print(s['b'])
Attempts:
2 left
💡 Hint
Remember that the index labels are used to access values in a Series.
✗ Incorrect
The Series has values [10, 20, 30] with index labels ['a', 'b', 'c']. Accessing s['b'] returns the value 20.
❓ data_output
intermediate1:30remaining
Length of Series after filtering
What is the length of the Series after filtering values greater than 15?
Pandas
import pandas as pd s = pd.Series([5, 15, 25, 35], index=['w', 'x', 'y', 'z']) filtered = s[s > 15] print(len(filtered))
Attempts:
2 left
💡 Hint
Count how many values are strictly greater than 15.
✗ Incorrect
Values greater than 15 are 25 and 35, so the filtered Series has length 2.
🔧 Debug
advanced2:00remaining
Identify the error in Series creation
What error does this code raise?
Pandas
import pandas as pd s = pd.Series([1, 2, 3], index=['a', 'b'])
Attempts:
2 left
💡 Hint
Check if the length of the data matches the length of the index.
✗ Incorrect
The data list has length 3 but the index list has length 2, causing a ValueError.
🚀 Application
advanced2:00remaining
Sum values of Series with specific labels
Given this Series, what is the sum of values for labels 'b' and 'd'?
Pandas
import pandas as pd s = pd.Series([100, 200, 300, 400], index=['a', 'b', 'c', 'd']) result = s[['b', 'd']].sum() print(result)
Attempts:
2 left
💡 Hint
Add the values corresponding to labels 'b' and 'd'.
✗ Incorrect
Values at 'b' and 'd' are 200 and 400, their sum is 600.
🧠 Conceptual
expert2:30remaining
Effect of duplicate labels in Series
What happens when you create a Series with duplicate index labels and then select by that label?
Pandas
import pandas as pd s = pd.Series([1, 2, 3, 4], index=['a', 'b', 'b', 'c']) result = s['b'] print(result)
Attempts:
2 left
💡 Hint
Think about how pandas handles duplicate index labels when selecting.
✗ Incorrect
When duplicate labels exist, selecting by that label returns a Series with all matching values.