0
0
Pandasdata~5 mins

Creating Series from list and dictionary in Pandas - Quick Revision & Summary

Choose your learning style9 modes available
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?
AA Series with values 10, 20, 30 and default index 0,1,2
BA DataFrame with 3 rows and 1 column
CA dictionary with keys 10, 20, 30
DAn error because list is not allowed
When creating a Series from a dictionary, what becomes the index?
AThe dictionary values
BAn empty index
CDefault numeric index 0,1,2,...
DThe dictionary keys
What will pd.Series({'a':1, 'b':2}, index=['b', 'c']) produce for the value at index 'c'?
A2
B0
CNaN
DError
How can you label a Series created from a list with custom names?
ABy changing the list values
BBy passing the <code>index</code> parameter with a list of labels
CBy converting it to a dictionary first
DYou cannot label a Series
Which of these is true about pandas Series?
AThey have an index and data values
BThey can only hold numbers
CThey cannot be created from dictionaries
DThey are two-dimensional like DataFrames
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.