What is a Pandas Series?
A
A two-dimensional data structure B
A labeled one-dimensional array C
A list of dictionaries D
A set of arrays
Analysis & Theory
A Series is a one-dimensional labeled array capable of holding any data type.
Which method is used to create a Series in Pandas?
A
pd.DataFrame() B
pd.Series() C
pd.Array() D
pd.List()
Analysis & Theory
Use `pd.Series()` to create a Pandas Series object.
What is the default index of a Series if not specified?
A
Starts at 1 B
Starts at 0 C
Random values D
Alphabet letters
Analysis & Theory
The default index in a Pandas Series starts at 0 and increases by 1.
What will `s[0]` return if `s = pd.Series([10, 20, 30])`?
A
10 B
0 C
20 D
Error
Analysis & Theory
`s[0]` accesses the first element, which is 10.
How can you assign custom labels (index) to a Series?
A
By using the `columns` parameter B
By using the `labels` parameter C
By using the `index` parameter D
By using the `name` parameter
Analysis & Theory
Use the `index` parameter to specify custom labels for the Series.
What does `s.values` return for a Series `s`?
A
Index of Series B
Length of Series C
List of values D
Underlying NumPy array
Analysis & Theory
`s.values` returns the data as a NumPy array.
What will `s.index` return for a Series `s`?
A
A list of values B
A NumPy array C
The index (labels) of the Series D
Data types
Analysis & Theory
`s.index` gives the Index object representing the labels of the Series.
Which of the following operations can be done on a Series?
A
Element-wise arithmetic B
String operations C
Logical comparison D
All of the above
Analysis & Theory
Series supports all the above operations because it's built on top of NumPy.
What will `s.name` return if `s` is a Series?
A
Name of the column B
Name of the Series C
Name of the index D
None of the above
Analysis & Theory
`s.name` stores or returns the name assigned to the Series.
Which of the following will convert a Python dictionary to a Series?
A
pd.Series(list) B
pd.Series(set) C
pd.Series(dict) D
pd.Series(array)
Analysis & Theory
You can create a Series from a dictionary using `pd.Series(dict)`; the keys become the index.