Data Science Questions and Answers Part-11

1. Which of the following is the base layer for all of the sparse indexed data structures?
a) SArray
b) SparseArray
c) PyArray
d) None of the mentioned

Answer: b
Explanation: SparseArray is a 1-dimensional ndarray-like object storing only values distinct from the fill_value.

2. Point out the correct statement.
a) All of the standard pandas data structures have a to_sparse method
b) Any sparse object can be converted back to the standard dense form by calling to_dense
c) The sparse objects exist for memory efficiency reasons
d) All of the mentioned

Answer: d
Explanation: The to_sparse method takes a kind argument and a fill_value.

3. Which of the following is not an indexed object?
a) SparseSeries
b) SparseDataFrame
c) SparsePanel
d) None of the mentioned

Answer: d
Explanation: SparseArray can be converted back to a regular ndarray by calling to_dense.

4. Which of the following list-like data structure is used for managing a dynamic collection of SparseArrays?
a) SparseList
b) GeoList
c) SparseSeries
d) All of the mentioned

Answer: a
Explanation: To create one, simply call the SparseList constructor with a fill_value.

5. Point out the wrong statement.
a) to_array. append can accept scalar values or any 2-dimensional sequence
b) Two kinds of SparseIndex are implemented
c) The integer format keeps an arrays of all of the locations where the data are not equal to the fill value
d) None of the mentioned

Answer: a
Explanation: to_array. append can accept scalar values or any 1-dimensional sequence.

6. Which of the following method is used for transforming a SparseSeries indexed by a MultiIndex to a scipy.sparse.coo_matrix?
a) SparseSeries.to_coo()
b) Series.to_coo()
c) SparseSeries.to_cooser()
d) None of the mentioned

Answer: a
Explanation: Experimental api to transform between sparse pandas and scipy.sparse structures.

7. The integer format tracks only the locations and sizes of blocks of data.
a) True
b) False

Answer: b
Explanation: The block format tracks only the locations and sizes of blocks of data.

8. Which of the following is used for testing for membership in the list of column names?
a) in
b) out
c) elseif
d) none of the mentioned

Answer: a
Explanation: For DataFrames, likewise, in applies to the column axis.

9. Which of the following indexing capabilities is used as a concise means of selecting data from a pandas object?
a) In
b) ix
c) ipy
d) none of the mentioned

Answer: b
Explanation: ix and reindex are 100% equivalent.

10. Pandas follow the NumPy convention of raising an error when you try to convert something to a bool.
a) True
b) False

Answer: a
Explanation: This happens in an if or when using the boolean operations, and, or, or not.