Recall & Review
beginner
What is a pandas Series?
A pandas Series is like a single column of data with labels (called an index). It can hold any data type and is one-dimensional.
Click to reveal answer
beginner
How do you create a Series from a list in pandas?
Use
pd.Series(your_list). The list values become the data, and pandas automatically creates a default index starting from 0.Click to reveal answer
beginner
How do you create a Series from a dictionary in pandas?
Use
pd.Series(your_dict). The dictionary keys become the index labels, and the values become the data in the Series.Click to reveal answer
intermediate
What happens if you create a Series from a list and specify a custom index?
The Series will use your custom index labels instead of the default 0,1,2,... This helps label data in a meaningful way.
Click to reveal answer
intermediate
Can a Series created from a dictionary have missing values?
Yes. If you specify an index with labels not in the dictionary keys, pandas fills those positions with
NaN (missing value).Click to reveal answer
What does
pd.Series([10, 20, 30]) create?✗ Incorrect
Creating a Series from a list assigns the list values as data and creates a default index starting at 0.
When creating a Series from a dictionary, what becomes the index?
✗ Incorrect
The keys of the dictionary become the index labels in the Series.
What will
pd.Series({'a':1, 'b':2}, index=['b', 'c']) produce for the value at index 'c'?✗ Incorrect
Since 'c' is not a key in the dictionary, pandas fills that position with NaN.
How can you label a Series created from a list with custom names?
✗ Incorrect
You can provide a list of labels to the
index parameter when creating the Series.Which of these is true about pandas Series?
✗ Incorrect
A Series is one-dimensional with an index and data values, and can hold any data type.
Explain how to create a pandas Series from a list and how the index is assigned by default.
Think about what happens if you don't give any index labels.
You got /3 concepts.
Describe how creating a Series from a dictionary works and what happens if you specify an index with labels not in the dictionary.
Consider how pandas matches dictionary keys to the index.
You got /3 concepts.