Challenge - 5 Problems
Series Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of Series from list with custom index
What is the output of this code creating a pandas Series from a list with a custom index?
Data Analysis Python
import pandas as pd s = pd.Series([10, 20, 30], index=['a', 'b', 'c']) print(s)
Attempts:
2 left
💡 Hint
Check how the index parameter changes the labels of the Series.
✗ Incorrect
The Series is created with values [10, 20, 30] and index labels ['a', 'b', 'c']. The dtype is int64 because the values are integers.
❓ data_output
intermediate1:30remaining
Length of Series from dict with missing keys
What is the length of the Series created from this dictionary with a specified index containing keys not in the dict?
Data Analysis Python
import pandas as pd d = {'x': 1, 'y': 2} s = pd.Series(d, index=['x', 'y', 'z']) print(len(s))
Attempts:
2 left
💡 Hint
Series length matches the index length, even if some keys are missing in the dict.
✗ Incorrect
The Series has index ['x', 'y', 'z'], so length is 3. The missing key 'z' gets a NaN value but counts as an element.
🔧 Debug
advanced2:00remaining
Identify the error in Series creation from dict with list values
What error does this code raise when creating a Series from a dictionary with list values?
Data Analysis Python
import pandas as pd d = {'a': [1, 2], 'b': [3, 4]} s = pd.Series(d) print(s)
Attempts:
2 left
💡 Hint
Check if pandas allows lists as values in Series from dict.
✗ Incorrect
Pandas allows lists as values in Series from dict. The Series will have keys as index and lists as values without error.
🧠 Conceptual
advanced1:30remaining
Behavior of Series creation from dict with partial index
When creating a pandas Series from a dictionary with a specified index that includes keys not in the dictionary, what value does pandas assign to those missing keys?
Attempts:
2 left
💡 Hint
Think about how pandas handles missing data in Series.
✗ Incorrect
Pandas assigns NaN to any index label not found in the dictionary when creating a Series with a specified index.
🚀 Application
expert2:00remaining
Create Series from dict with mixed types and analyze output
Given this dictionary with mixed value types, what is the dtype of the resulting Series?
Data Analysis Python
import pandas as pd d = {'a': 1, 'b': 2.5, 'c': '3'} s = pd.Series(d) print(s.dtype)
Attempts:
2 left
💡 Hint
Consider how pandas handles mixed data types in a Series.
✗ Incorrect
When a Series has mixed types (int, float, string), pandas uses dtype 'object' to hold all types.