Challenge - 5 Problems
Series Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Why is a Pandas Series considered a 1D data structure?
Which of the following best explains why a Pandas Series is called a 1D data structure?
Attempts:
2 left
💡 Hint
Think about how data is arranged in a Series compared to a DataFrame.
✗ Incorrect
A Pandas Series holds data in a single column with an associated index, making it one-dimensional. It is like a list with labels.
❓ Predict Output
intermediate2:00remaining
Output of Series shape
What is the output of the following code?
Data Analysis Python
import pandas as pd s = pd.Series([10, 20, 30, 40]) print(s.shape)
Attempts:
2 left
💡 Hint
Check the shape attribute of a Series returns a tuple representing its dimensions.
✗ Incorrect
The shape of a Series is a tuple with one element showing the number of rows, e.g., (4,). This confirms it is 1D.
❓ data_output
advanced2:30remaining
Index and values of a Series
Given the Series below, what is the output of s.index and s.values?
Data Analysis Python
import pandas as pd s = pd.Series([5, 10, 15], index=['a', 'b', 'c']) print(s.index) print(s.values)
Attempts:
2 left
💡 Hint
Look at the types returned by s.index and s.values.
✗ Incorrect
The index is a pandas Index object showing labels, and values is a numpy array of the data.
🔧 Debug
advanced2:00remaining
Error when accessing Series with multiple indices
What error will this code produce and why?
import pandas as pd
s = pd.Series([1, 2, 3])
print(s[0,1])
Data Analysis Python
import pandas as pd s = pd.Series([1, 2, 3]) print(s[0,1])
Attempts:
2 left
💡 Hint
Consider how Series indexing works with single vs multiple keys.
✗ Incorrect
Series indexing expects a single key. Using a tuple (0,1) as key causes a KeyError because that key does not exist.
🚀 Application
expert2:30remaining
Using Series to represent time series data
You have daily temperature data for a week stored in a Pandas Series with dates as index. Which of the following code snippets correctly selects the temperature for '2024-06-03'?
Data Analysis Python
import pandas as pd dates = pd.date_range('2024-06-01', periods=7) temps = pd.Series([22, 23, 21, 20, 19, 18, 17], index=dates)
Attempts:
2 left
💡 Hint
Use label-based indexing to select by date label.
✗ Incorrect
temps.loc['2024-06-03'] selects the value by label (date). temps['2024-06-03'] also works but can be ambiguous. iloc expects integer position, so option A is wrong. temps[3] selects by position, not date.