Data Science Multiple Choice Questions on “Pandas Data Structure”.
1. Which of the following thing can be data in Pandas?
a) a python dict
b) an ndarray
c) a scalar value
d) all of the mentioned
Answer: d
Explanation: The passed index is a list of axis labels.
2. Point out the correct statement.
a) If data is a list, if index is passed the values in data corresponding to the labels in the index will be pulled out
b) NaN is the standard missing data marker used in pandas
c) Series acts very similarly to a array
d) None of the mentioned
Answer: b
Explanation: If data is a dict, if index is passed the values in data corresponding to the labels in the index will be pulled out.
3. The result of an operation between unaligned Series will have the ________ of the indexes involved.
a) intersection
b) union
c) total
d) all of the mentioned
Answer: b
Explanation: If a label is not found in one Series or the other, the result will be marked as missing NaN.
4. Which of the following input can be accepted by DataFrame?
a) Structured ndarray
b) Series
c) DataFrame
d) All of the mentioned
Answer: d
Explanation: DataFrame is a 2-dimensional labeled data structure with columns of potentially different types.
5. Point out the wrong statement.
a) A DataFrame is like a fixed-size dict in that you can get and set values by index label
b) Series can be be passed into most NumPy methods expecting an ndarray
c) A key difference between Series and ndarray is that operations between Series automatically align the data based on label
d) None of the mentioned
Answer: a
Explanation: A Series is like a fixed-size dict in that you can get and set values by index label.
6. Which of the following takes a dict of dicts or a dict of array-like sequences and returns a DataFrame?
a) DataFrame.from_items
b) DataFrame.from_records
c) DataFrame.from_dict
d) All of the mentioned
Answer: a
Explanation: DataFrame.from_dict operates like the DataFrame constructor except for the orient parameter which is ‘columns’ by default.
7. Series is a one-dimensional labeled array capable of holding any data type.
a) True
b) False
Answer: a
Explanation: The axis labels are collectively referred to as the index.
8. Which of the following works analogously to the form of the dict constructor?
a) DataFrame.from_items
b) DataFrame.from_records
c) DataFrame.from_dict
d) All of the mentioned
Answer: a
Explanation: DataFrame.from_records takes a list of tuples or an ndarray with structured dtype.
9. Which of the following operation works with the same syntax as the analogous dict operations?
a) Getting columns
b) Setting columns
c) Deleting columns
d) All of the mentioned
Answer: d
Explanation: You can treat a DataFrame semantically like a dict of like-indexed Series objects.
10. If data is an ndarray, index must be the same length as data.
a) True
b) False
Answer: a
Explanation: If no index is passed, one will be created having values [0, …, len(data) – 1].