Identify the statements which are true for NumPy and Pandas Series:
A. A Series can only hold numeric data.
B. A NumPy array has an implicitly defined index associated with each element.
C. A Series can hold different types of data.
D. The two common ways of accessing the elements of a series are Indexing and Slicing.
Identify the statements which are true for NumPy and Pandas Series:
A. A Series can only hold numeric data.
B. A NumPy array has an implicitly defined index associated with each element.
C. A Series can hold different types of data.
D. The two common ways of accessing the elements of a series are Indexing and Slicing.
Solution
Statements B, C and D are true.
B: a NumPy array elements are located by an implicit integer position (0, 1, 2, ...), whereas a Series has an explicitly defined index that can be labels.
C: a Series can hold integers, floats, strings, Python objects and so on, so it can store mixed types (dtype becomes object).
D: elements of a Series are accessed by indexing (for example s[0] or s['a']) and slicing (for example s[1:3]).
Statement A is false: a Series is not limited to numeric data, it can hold strings, booleans and other objects. This rules out Options 1, 2 and 3.
Related questions:
2025: 27 May Shift 2
2025: 13 May Shift 2