Python Pandas MCQ Questions And Answers
This section focuses on "Python Pandas" for Data Science. These Python Pandas Multiple Choice Questions (MCQ) should be practiced to improve the Data Science skills required for various interviews (campus interview, walk-in interview, company interview), placements, entrance exams and other competitive examinations.
1. Pandas is an open-source _______ Library?
A. Ruby
B. Javascript
C. Java
D. Python
View Answer
Ans : D
Explanation: Pandas is an open-source Python Library providing high-performance data manipulation and analysis tool using its powerful data structures.
2. Pandas key data structure is called?
A. Keyframe
B. DataFrame
C. Statistics
D. Econometrics
View Answer
Ans : B
Explanation: Pandas is built on the Numpy package and its key data structure is called the DataFrame.
3. In pandas, Index values must be?
A. unique
B. hashable
C. Both A and B
D. None of the above
View Answer
Ans : C
Explanation: Index values must be unique and hashable, same length as data. Default np.arrange(n) if no index is passed.
4. Which of the following is correct Features of DataFrame?
A. Potentially columns are of different types
B. Can Perform Arithmetic operations on rows and columns
C. Labeled axes (rows and columns)
D. All of the above
View Answer
Ans : D
Explanation: All the above are feature of dataframe.
5. A panel is a ___ container of data
A. 1D
B. 2D
C. 3D
D. Infinite
View Answer
Ans : C
Explanation: A panel is a 3D container of data. The term Panel data is derived from econometrics and is partially responsible for the name pandas : pan(el)-da(ta)-s.
6. Which of the following is true?
A. If data is an ndarray, index must be the same length as data.
B. Series is a one-dimensional labeled array capable of holding any data type.
C. Both A and B
D. None of the above
View Answer
Ans : C
Explanation: Both option A and B are true.
7. 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 above
View Answer
Ans : A
Explanation: DataFrame.from_dict operates like the DataFrame constructor except for the orient parameter which is 'columns' by default.
8. Which of the following makes use of pandas and returns data in a series or dataFrame?
A. pandaSDMX
B. freedapi
C. OutPy
D. Inpy
View Answer
Ans : B
Explanation: freedapi module requires a FRED API key that you can obtain for free on the FRED website.
9. What will be output for the following code?
import pandas as pd
import numpy as np
s = pd.Series(np.random.randn(4))
print s.ndim
A. 0
B. 1
C. 2
D. 3
View Answer
Ans : B
Explanation: Returns the number of dimensions of the object. By definition, a Series is a 1D data structure, so it returns 1.
10. 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. iy
View Answer
Ans : B
Explanation: ix and reindex are 100% equivalent.
Discussion