Data Science Questions and Answers – Pandas Data Structure

This set of Data Science Multiple Choice Questions & Answers (MCQs) focuses 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
View Answer

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

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

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

Answer: d
Explanation: DataFrame is a 2-dimensional labeled data structure with columns of potentially different types.

advertisement
advertisement

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

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

Answer: a
Explanation: DataFrame.from_dict operates like the DataFrame constructor except for the orient parameter which is ‘columns’ by default.

Note: Join free Sanfoundry classes at Telegram or Youtube

7. Series is a one-dimensional labeled array capable of holding any data type.
a) True
b) False
View Answer

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

Answer: a
Explanation: DataFrame.from_records takes a list of tuples or an ndarray with structured dtype.

advertisement

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

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

Answer: a
Explanation: If no index is passed, one will be created having values [0, …, len(data) – 1].

advertisement

Sanfoundry Global Education & Learning Series – Data Science.

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

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.