Python Pandas Class 12 MCQ Questions Part 1
Question . 1.
To create an empty series object, you can use:
(a) p(d)Series(empty)
(b) p(d)Series(np.NaN)
(c) p(d)Series( )
(d) All of these
Answer:
(c) p(d)Series( )
Question 2.
To specify datatype int 16 for a series object,you can write:
(a) p(d)Series(data = array, dtype = int16)
(b) p(d)Series(data = array, dtype = numpy.int 16)
(c) p(d)Series(data= array.dtype = pandas.int 16)
(d) All of the above
Answer:
(b) p(d)Series(data = array, dtype = numpy.int16)
Question 3.
To get the number of dimensions of a series object, attribute is displaye(d)
(a) index
(b) size
(c) itemsize
(d) ndim
Answer:
(d) ndim
Question 4.
To get the size of the datatype of the items in series object, you can display attribute.
(a) index
(b) size
(c) itemsize
(d) ndim
Answer:
(c) itemsize
Question 5.
To get the number of elements in a series object, attribute may be use(d)
(a) index
(b) size
(c) itemsize
(d) ndim
Answer:
(b) size
Question 6.
To get the number of bytes of the series data, attribute is displaye(d)
(a) hasnans
(b) nbytes
(c) ndim
(d) dtype
Answer:
(b) nbytes
Question 7.
To check if the series object contains NaN values, attribute is displaye(d)
(a) hasnans
(b) n bytes
(c) n dim
(d) dtype
Answer:
(a) hasnans
Question 8.
To display third element of a series object S, you will write
(a) S(:3)
(b) S[2]
(c) S[3]
(d) S[:2]
Answer:
(b) 5(2]
Question 9.
To display first three elements of a series object S, you may write
(a) S(:3]
(b) 5(3]
(c) 5 (3rd]
(d) All of these
Answer:
(a) S(:3]
Question 10.
To display last five rows of a series object S, you may write
(a) head()
(b) head(5)
(c) tail()
(d) tail(5)
Answer:
(c) tail(), (d) tail(5)
Question 11.
Missing data in Pandas object is represented through:
(a) Null
(b) None
(c) Missing
(d) NaN
Answer:
(d) NaN
Question 12.
Given a Pandas series called SeQuestion uences, the command which will display the first 4 rows is
(a) print(SeQuestion uences.head(4))
(b) print (SeQuestion uences. Head(4))
(c) print(SeQuestion uences.heads(4)
(d) print(SeQuestion uences.Heads(4))
Answer:
(a) print(SeQuestion uences.head(4))
Question 13.
If a dataframe is created using a 2D dictionary, then the indexes/row labels are formed from
(a) dictionary’s values
(b) inner dictionary’s keys
(c) outer dictionary’s keys
(d) None of these
Answer:
(b) inner dictionary’s keys
Question 14.
If a dataframe is created using a 2D dictionary, then the column labels are formed from
(a) dictionary’s values
(b) inner dictionary’s keys
(c) outer dictionary’s keys
(d) None of these
Answer:
(c) outer dictionary’s keys
Question 15.
The axis 0 identifies a dataframe’s
(a) rows
(b) columns
(c) values
(d) datatype
Answer:
(a) rows
Question 16.
The axis 1 identifies a dataframe’s
(a) rows
(b) columns
(c) values
(d) datatype
Answer:
(b) columns
Question 17.
To get the number of elements in a dataframe attribute may be use(d)
(a) size
(b) shape
(c) values
(d) ndim
Answer:
(a) size
Question 18.
To get NumPy representation of a dataframe ……… attribute may be use(d)
(a) size
(b) shape
(c) values
(d) ndim
Answer:
(c) values
Question 19.
To get a number representing number of axes in a dataframe, ……….. attribute may be use(d)
(a) size
(b) shape
(c) values
(d) ndim
Answer:
(d) ndim
Question 20.
To get the transpose of a dataframe Dl, you can write
(a) D1.T
(b) D1. Transpose
(c) D1.Swap
(d) All of these
Answer:
(a) D1.T
Question 21.
To extract row/column from a dataframe,……….. function may be use(d)
(a) row( )
(b) column( )
(c) loc( )
(d) All of these
Answer:
(c) loc( )
Question 22.
To display the 3rd, 4th and 5th columns from the 6th to 9th rows of a dataframe DF,you can write
(a) DF.loc[6:9, 3:5]
(b) DF.loc[6:10, 3:6]
(c) DF.iloc(6:10, 3:6]
(d) DF.iloc[6:9, 3:5]
Answer:
(c) DF.iloc[6:10,3:6]
Question 23.
To change the 5th column’s value at 3rd row as 35 in dataframe DF, you can write
(a) DF(4, 6] = 35
(b) DF(3, 5] = 35
(c) DF.iat(4, 6] = 35
(d) DF.iat(3, 5] = 35 .
Answer:
(d) DF.iat(3, 5] = 35
Question 24.
Which among the following options can be used to create a dataframe in Pandas?
(a) A scalar value
(b) An ndarray
(c) A python diet
(d) All of these
Answer:
(d) All of these
Question 25.
Identify the correct statement:
(a) The standard marker for missing data in Pandas is NaN
(b) Series act in a way similar to that of an array
(c) Both (a) and (b)
(d) None of the above
Answer:
(c) Both (a) and (b)
Question 26.
To delete a column from a dataframe, you may use statement.
(a) remove
(b) del
(c) drop
(d) cancel
Answer:
(b) del
Question 27.
To delete a rowfrom a DataFrame.you may use……… statement.
(a) remove
(b) del
(c) drop
(d) cancel
Answer:
(c) drop
Question 28
……… is a popular data-science library of Python.
(a) numpy
(b) pandas
(c) Both (a) and (b)
(d) None of these
Answer:
(b) pandas
Question 29.
A ………… is a Pandas data structure that represents a ID array like object.
(a) dataframe
(b) vector
(c) series
(d) All of these
Answer:
(c) series
Question 30.
A is a Pandas data structure that represents ……… a 2D array like object.
(a) dataframe
(b) vector
(c) series
(d) All of these
Answer:
(a) dataframe
Question 31.
You can use numpy …… for missing dat(a)
(a) none
(b) no
(c) NaN
(d) None of these
Answer:
(c) NaN
Question 32.
To specify datatype for a series object …… argument is use(d)
(a) ctype
(b) atype
(c) ntype
(d) dtype
Answer:
(d) dtype
Question 33.
The function on series object returns total ……. elements in it including NaNs.
(a) gen( )
(b) len( )
(c) gen( )
(d) cen( )
Answer:
(b) len()
Question 34.
The function on series object returns only the count of non-NaN values in it.
(a) acount( )
(b) allcount( )
(c) count( )
(d) dcount( )
Answer:
(c) count( )
Question 35.
Series is mutable.
(a) non- value
(b) text
(c) numeric
(d) value
Answer:
(d) value
Question 36.
Series is not ……… mutable.
(a) size
(b) variable
(c) shape
(d) value
Answer:
(a) size
Question 37.
Dataframe is …….. mutable as well as ………..mutable.
(a) value, size
(b) size, value
(c) size, size
(d) value, value
Answer:
(b) size, value
Question 38.
In a dataframe, Axis = 1 represents the ……… elements.
(a) row
(b) record
(c) column
(d) None of these
Answer:
(c) column
Question 39.
To access values using row labels you can use DF
(a) loc
(b) voc
(c) doc
(d) toe
Answer:
(a) loc
Question 40.
To access individual value, you can use DF …….. using row/column index labels.
(a) in
(b) or
(c) more
(d) at
Answer:
(d) at
Question 41.
To access individual value, you can use DF ……. using row/column integer position.
(a) lot
(b) doc
(c) toe
(d) iat
Answer:
(d) iat
Question 42.
The rename() function requires argument ……… to make changes in the original dataframe.
(a) outplace()
(b) atplace
(c) inplace
(d) ofplace
Answer:
(c) inplace
Question 43.
Which of the following are modules/libraries in Python?
(a) NumPy
(b) Pandas
(c) Matplotlib
(d) All of these
Answer:
(d) All of these
Question 44.
NumPy stands for ……….
(a) Number Python
(b) Numerical Python
(c) Numbers in Python
(d) None of these
Answer:
(b) Numerical Python
Question 45.
Which of the following libraries allows to manipulate, transform and visualize data easily and efficiently?
(a) Pandas
(b) NumPy
(c) Matplotlib
(d) All of these
Answer:
(d) All of these
Question 46.
PANDAS stands for……….
(a) Panel Data Analysis
(b) Panel Data Analyst
(c) Panel Data
(d) Panel Dashboard
Answer:
(c) Panel Data
Question 47.
……… is an important library used for analysing dat(a)
(a) Math
(b) Random
(c) Pandas
(d) None of these
Answer:
(c) Pandas
Question 48.
Important data structure of pandas is/are
(a) series
(b) dataframe
(c) Both of the above
(d) None of these
Answer:
(c) Both of the above
Question 49.
Which of the following library in Python is used for plotting graphs and visualization?
(a) Pandas
(b) NumPy
(c) Matplotlib
(d) None of these
Answer:
(c) Matplotlib
Question 50.
Pandas series can have data types.
(a) float
(b) integer
(c) string
(d) All of these
Answer:
(d) All of these
Question 51
…….. is used when data is in Tabular Format.
(a) NumPy
(b) Pandas
(c) Matplotlib
(d) All of these
Answer:
(b) Pandas
Question 52.
Which of the following command is used to install pandas?
(a) pip install pandas
(b) install pandas
(c) pip pandas
(d) None of these
Answer:
(a) pip install pandas
Question 53.
A is a collection of data values and operations that can be applied to that dat(a)
(a) data structure
(b) dataframe
(c) table
(d) None of these
Answer:
(a) data structure
Question 54.
A is a one-dimensional array.
(a) dataframe
(b) series .
(c) Both of the above
(d) None of these
Answer:
(b) series
Question 55.
Which of the following statement is wrong?
(a) We can create Series from Dictionary in Python,
(b) Keys of dictionary become index of the series.
(c) Order of indexes created from Keys may not be in the same order as typed in dictionary.
(d) All are correct
Answer:
(d) All are correct
Question 56.
A Series by default have numeric data labels starting from
(a) 3
(b) 2
(c) 1
(d) 0
Answer:
(d) 0
Question 57.
The data label associated with a particular value of Series is called its
(a) Data value
(b) Index
(c) Value
(d) None of these
Answer:
(b) Index
Question 58.
Which of the following module is to be imported to create Series?
(a) NumPy
(b) Pandas
(c) Matplotlib
(d) None of these
Answer:
(b) Pandas
Question 59.
Which of the following function/method help to create Series?
(a) series( )
(b) 5eries( )
(c) createSeries( )
(d) None of these
Answer:
(b) Series( )
Question 60.
Write the output of the following:
>>> import pandas as pd
>>> seriesl = p(d)Series(10,20,30)
>>> print(seriesl)
(a) Output:
0 10
1 20
2 30
dtype: int64
(b) Output:
10
20
30
dtype: int64
(c) Output:
0
1
2
dtype: int64
(d) None of these
Answer:
(a) Output:
0 10
1 20
2 30
dtype: int64
Question 61.
When you print/display any series then the left most column is showing value.
(a) index
(b) data
(c) value
(d) None of these
Answer:
(a) index
Question 62.
How many values will be there in arrayl, if given code is not returning any error?>>> series4 = p(d)Series(arrayl, index = [“Jan”, “Feb”, “Mar”, “Apr”])
(a) 1
(b) 2
(c) 3
(d) 4
Answer:
(d) 4
Question 63.
Which of the following statement will create an empty series named “SI”?
(a) 51 = p(d)Series(None)
(b) 51 = p(d)5eries()
(c) Both of the above
(d) None of these
Answer:
(c) Both of the above
Question 64.
How many elements will be there in the series named “SI”? »> SI = p(d)Series(range(5)) >» print(Sl)
(a) 5
(b) 4
(c) 6
(d) None of these
Answer:
(a) 5
Question 65.
When we create a series from dictionary then the keys of dictionary become
(a) index of the series
(b) value of the series
(c) caption of the series
(d) None of these
Answer:
(a) index of the series
Question 66.
Write the output of the following:>>> Sl=p(d)Series(14, index = [‘a’, ‘b’, ‘c’]) >>> print(Sl)
(a) a 14
b 14
c 14
dtype: int64
(b) a 14
dtype: int64
(c) Error
(d) None of these
Answer:
(a) a 14
b 14
c 14
dtype: int64
Question 67.
Write the output of the following: >>>Sl=p(d)Series([14,7, index = [‘a’, ‘b’, ‘c’]) >>> print(Sl)
(a) a 14
b 7
c 7
(b) a 14
b 7
dtype: int64
(c) Error
(d) None of these
Answer:
(c) Error
Question 68.
Write the output of the following:
>>> Sl=p(d)Series([14,7,9] .index = range(l, 8,3)) >>> print(Sl)
(a) 14 1
7 4
9 7
dtype: int64
(b) 1 14
47
7 9
dtype: int64
(c) Error
(d) None of these
Answer:
(b) 1 14
47
79
dtype: int64
Question 69.
Which of the following code will generate the following output?
Jan 31
Feb 28
Mar 31 dtype: int64
(a) import pandas as pd
51 = p(d)Series(data = [31,28,31], index=[“Jan”,”Feb”,,,Mar”]) print(SI)
(b) import pandas as pd
S1 = p(d)Series((31,28,31], index=[“Jan”,”Feb”,”Mar”]) print(SI)
(c) Both of the above
(d) None of the above
Answer:
(c) Both of the above
Question 70.
Write the output of the following: import pandas as pd SI = p(d)Series(data = range(31, 2, -6), index = [x for x in “aeiou”]) print(Sl)
(a) a 31
e 25
i 19
o 13
u 7
dtype: int64
(b) a 31
e 25
i 19
dtype: int64
(c) Error
(d) None of these
Answer:
(a) a 31
e 25
i 19
o 13
u 7
dtype: int64
Question 71.
What type of error is returned by following code? import pandas as pd SI = p(d)Series(data = (31,2, -6), index = [7,9,3,2]) print(Sl)
(a) SyntaxError
(b) IndexError
(c) ValueError
(d) None of these
Answer:
(c) ValueError
Question 72.
Write the output of the following: import pandas as pd SI = p(d)Series(data – 2*(31,2,-6)) print(Sl)
(a) 0 31
12
2-6
dtype: int64
(b) 0 31
12
2-6
3 31
4 2
dtype: int64
(c) 0 31
12
2-6
3 31
4 2
5 -6
dtype: int64
(d) 0 31
12
2-6
3 31
dtype: int64
Answer:
(d) 0 31
12
2-6
3 31
dtype: int64
Question 73.
We can imagine a Pandas series as a …….. spreadsheet.
(a) column
(b) cell
(c) table
(d) None of these
Answer:
(a) column
Question 74.
We can assign user-defined labels to the index of the series
(a) True
(b) False
(c) Error
(d) None of these
Answer:
(a) True
Question 75.
Write the output of the following: import pandas as pd series2 = p(d)Series([“Kavi7Shyam7Ravi”], index=[3,5 print(series2 > “S”)
(a) 3 False
5 False
1 False
dtype: bool
(b) 3 False
5 False
1 False
dtype: bool
(c) 3 True
5 True
1 True
dtype: bool
(d) None of these
Answer:
(b) 3 False
5 False
1 False
dtype: bool