Data Science Questions and Answers – Pandas – 3

This set of Data Science Questions and Answers for experienced focuses on “Pandas – 3”

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
View Answer

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
View Answer

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
View Answer

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
View Answer

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

advertisement
advertisement

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
View Answer

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
View Answer

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

Note: Join free Sanfoundry classes at Telegram or Youtube

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

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
View Answer

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

advertisement

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
View Answer

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
View Answer

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

advertisement

Sanfoundry Global Education & Learning Series – Data Science.

Here’s the list of Best Books in Data Science.

To practice all areas of Data Science for Experienced, Here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.