Python Pandas MCQs
11. Python pandas was developed by?
A. Guido van Rossum
B. Travis Oliphant
C. Wes McKinney
D. Brendan Eich
View Answer
Ans : C
Explanation: Pandas is a high-level data manipulation tool developed by Wes McKinney.
12. What will be output for the following code?
import pandas as pd
s = pd.Series([1,2,3,4,5],index = ['a','b','c','d','e'])
print s['a']
A. 1
B. 2
C. 3
D. 4
View Answer
Ans : A
Explanation: Retrieve a single element using index label value.
13. What will be correct syntax for pandas series?
A. pandas_Series( data, index, dtype, copy)
B. pandas.Series( data, index, dtype)
C. pandas.Series( data, index, dtype, copy)
D. pandas_Series( data, index, dtype)
View Answer
Ans : C
Explanation: A pandas Series can be created using the following constructor : pandas.Series( data, index, dtype, copy)
14. What will be syntax for pandas dataframe?
A. pandas.DataFrame( data, index, dtype, copy)
B. pandas.DataFrame( data, index, rows, dtype, copy)
C. pandas_DataFrame( data, index, columns, dtype, copy)
D. pandas.DataFrame( data, index, columns, dtype, copy)
View Answer
Ans : D
Explanation: A pandas DataFrame can be created using the following constructor : pandas.DataFrame( data, index, columns, dtype, copy)
15. Axis 1, in panel represent?
A. minor_axis
B. major_axis
C. items
D. None of the above
View Answer
Ans : B
Explanation: major_axis : axis 1, it is the index (rows) of each of the DataFrames.
16. 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 above
View Answer
Ans : D
Explanation: The passed index is a list of axis labels.
17. The ________ project builds on top of pandas and matplotlib to provide easy plotting of data.
A. yhat
B. Seaborn
C. Vincent
D. Pychart
View Answer
Ans : B
Explanation: Seaborn has great support for pandas data objects.
18. Why ndim is used?
A. Returns the number of elements in the underlying data.
B. Returns the Series as ndarray.
C. Returns the number of dimensions of the underlying data, by definition 1.
D. Returns a list of the axis labels
View Answer
Ans : C
Explanation: ndim : Returns the number of dimensions of the underlying data, by definition 1
19. What will be output for the following code?
import pandas as pd
import numpy as np
s = pd.Series(np.random.randn(2))
print s.size
A. 0
B. 1
C. 2
D. 3
View Answer
Ans : C
Explanation: size : Returns the size(length) of the series.
20. Which of the following is false?
A. The integer format tracks only the locations and sizes of blocks of data.
B. Pandas follow the NumPy convention of raising an error when you try to convert something to a bool.
C. Two kinds of SparseIndex are implemented
D. The integer format keeps an arrays of all of the locations where the data are not equal to the fill value
View Answer
Ans : A
Explanation: The block format tracks only the locations and sizes of blocks of data.
Discussion