Chapter -1 Python Pandas MCQ
MCQ
Pandas MCQs
1. Which library is used for data analysis in Python?
- (a) NumPy
- (b) Pandas
- (c) Matplotlib
- (d) Turtle
Answer: (b) Pandas
2. Which statement is used to import Pandas?
- (a) import pandas
- (b) import pandas as pd
- (c) pandas import pd
- (d) import pd
Answer: (b) import pandas as pd
3. Pandas is mainly used for:
- (a) Graphics
- (b) Data Analysis
- (c) Gaming
- (d) Networking
Answer: (b) Data Analysis
4. A Series in Pandas is:
- (a) Two-dimensional
- (b) Three-dimensional
- (c) One-dimensional
- (d) Multi-dimensional
Answer: (c) One-dimensional
5. Which function creates a Series?
- (a) pd.DataFrame()
- (b) pd.Series()
- (c) pd.Array()
- (d) pd.List()
Answer: (b) pd.Series()
6. A DataFrame is:
- (a) One-dimensional
- (b) Two-dimensional
- (c) Three-dimensional
- (d) Scalar
Answer: (b) Two-dimensional
7. Which function creates a DataFrame?
- (a) pd.Frame()
- (b) pd.Table()
- (c) pd.DataFrame()
- (d) pd.Matrix()
Answer: (c) pd.DataFrame()
8. What is the default index of a Series?
- (a) Starts from 1
- (b) Starts from -1
- (c) Starts from 0
- (d) User-defined only
Answer: (c) Starts from 0
9. Which attribute returns the dimensions of a DataFrame?
- (a) size
- (b) shape
- (c) ndim
- (d) info
Answer: (b) shape
10. Which attribute returns the total number of elements?
- (a) count
- (b) size
- (c) shape
- (d) ndim
Answer: (b) size
11. Which attribute returns the number of dimensions?
- (a) ndim
- (b) size
- (c) shape
- (d) info
Answer: (a) ndim
12. What is the output of ndim for a Series?
- (a) 0
- (b) 1
- (c) 2
- (d) 3
Answer: (b) 1
13. What is the output of ndim for a DataFrame?
- (a) 1
- (b) 0
- (c) 2
- (d) 3
Answer: (c) 2
14. Which function displays the first 5 rows of a DataFrame?
- (a) top()
- (b) first()
- (c) head()
- (d) start()
Answer: (c) head()
15. Which function displays the last 5 rows?
- (a) tail()
- (b) end()
- (c) last()
- (d) bottom()
Answer: (a) tail()
16. What does df.head(3) display?
- (a) Last 3 rows
- (b) First 3 rows
- (c) Middle 3 rows
- (d) Random 3 rows
Answer: (b) First 3 rows
17. Which function gives concise information about a DataFrame?
- (a) describe()
- (b) summary()
- (c) info()
- (d) details()
Answer: (c) info()
18. Which function generates statistical summary?
- (a) stats()
- (b) summary()
- (c) describe()
- (d) info()
Answer: (c) describe()
19. Which attribute returns column names?
- (a) labels
- (b) columns
- (c) names
- (d) header
Answer: (b) columns
20. Which attribute returns row labels?
- (a) rows
- (b) labels
- (c) index
- (d) names
Answer: (c) index
21. Which function returns data types of columns?
- (a) types()
- (b) dtype()
- (c) dtypes
- (d) datatypes()
Answer: (c) dtypes
22. What is the default number of rows shown by head()?
- (a) 3
- (b) 4
- (c) 5
- (d) 10
Answer: (c) 5
23. Which function is used to read a CSV file?
- (a) open_csv()
- (b) csvread()
- (c) read_csv()
- (d) load_csv()
Answer: (c) read_csv()
24. Which function saves a DataFrame to CSV?
- (a) save_csv()
- (b) write_csv()
- (c) to_csv()
- (d) export_csv()
Answer: (c) to_csv()
25. Which method returns maximum value?
- (a) highest()
- (b) max()
- (c) large()
- (d) maximum()
Answer: (b) max()
26. Which method returns minimum value?
- (a) min()
- (b) low()
- (c) minimum()
- (d) smallest()
Answer: (a) min()
27. Which method returns average value?
- (a) avg()
- (b) mean()
- (c) average()
- (d) median()
Answer: (b) mean()
28. Which method returns median?
- (a) mean()
- (b) avg()
- (c) median()
- (d) mode()
Answer: (c) median()
29. Which method returns most frequent value?
- (a) median()
- (b) mean()
- (c) mode()
- (d) freq()
Answer: (c) mode()
30. Which method counts non-null values?
- (a) count()
- (b) len()
- (c) size()
- (d) total()
Answer: (a) count()
31. Which method sorts values?
- (a) sort()
- (b) arrange()
- (c) sort_values()
- (d) order()
Answer: (c) sort_values()
32. Which method sorts indexes?
- (a) sort_index()
- (b) sort()
- (c) arrange()
- (d) index_sort()
Answer: (a) sort_index()
33. Which function checks null values?
- (a) isnull()
- (b) empty()
- (c) null()
- (d) checknull()
Answer: (a) isnull()
34. Which function removes null values?
- (a) remove_null()
- (b) dropna()
- (c) delete_null()
- (d) clearna()
Answer: (b) dropna()
35. Which function replaces null values?
- (a) replace()
- (b) fillna()
- (c) update()
- (d) modify()
Answer: (b) fillna()
36. Which attribute returns column count and row count?
- (a) size
- (b) shape
- (c) ndim
- (d) info
Answer: (b) shape
37. What does shape return?
- (a) Total elements
- (b) Tuple (rows, columns)
- (c) Columns only
- (d) Rows only
Answer: (b) Tuple (rows, columns)
38. Which function returns standard deviation?
- (a) variance()
- (b) std()
- (c) mean()
- (d) median()
Answer: (b) std()
39. Which function returns variance?
- (a) std()
- (b) var()
- (c) variance()
- (d) mean()
Answer: (b) var()
40. What is the output type of Series?
- (a) One-dimensional labeled array
- (b) Table
- (c) Matrix
- (d) Scalar
Answer: (a) One-dimensional labeled array
41. A DataFrame consists of:
- (a) Rows only
- (b) Columns only
- (c) Multiple Series
- (d) Arrays only
Answer: (c) Multiple Series
42. Which function displays top records?
- (a) head()
- (b) tail()
- (c) info()
- (d) count()
Answer: (a) head()
43. Which function displays bottom records?
- (a) head()
- (b) tail()
- (c) describe()
- (d) info()
Answer: (b) tail()
44. Which method converts DataFrame into NumPy array?
- (a) toarray()
- (b) values
- (c) tonumpy()
- (d) array()
Answer: (b) values
45. Which attribute shows memory usage and data types?
- (a) describe()
- (b) info()
- (c) shape
- (d) size
Answer: (b) info()
46. What does df.columns return?
- (a) Row names
- (b) Column names
- (c) Values
- (d) Indexes
Answer: (b) Column names
47. What does df.index return?
- (a) Column labels
- (b) Row labels
- (c) Values
- (d) Data types
Answer: (b) Row labels
48. Which method can rename columns?
- (a) rename()
- (b) change()
- (c) modify()
- (d) replace()
Answer: (a) rename()
49. Which function displays complete statistical analysis?
- (a) stats()
- (b) describe()
- (c) info()
- (d) summary()
Answer: (b) describe()
50. Pandas is built on top of:
- (a) Python Turtle
- (b) NumPy
- (c) MySQL
- (d) Matplotlib
Answer: (b) NumPy
51. Which function is used to display the first 10 records of a DataFrame?
- (a) df.top(10)
- (b) df.head(10)
- (c) df.first(10)
- (d) df.show(10)
Answer: (b) df.head(10)
52. Consider the following DataFrame:
import pandas as pd
df = pd.DataFrame({
'Name':['Amit','Riya','Karan'],
'Marks':[85,90,78]
})
What will be the output of df.shape?
- (a) (2,3)
- (b) (3,2)
- (c) (3,3)
- (d) 6
Answer: (b) (3,2)
53. Which attribute returns the total number of rows and columns in a DataFrame?
- (a) size
- (b) ndim
- (c) shape
- (d) count
Answer: (c) shape
54. What is the output of:
df = pd.DataFrame({'A':[10,20,30]})
print(df.size)
- (a) 1
- (b) 2
- (c) 3
- (d) (3,1)
Answer: (c) 3
55. Which method is used to display summary statistics of numerical columns?
- (a) info()
- (b) count()
- (c) describe()
- (d) dtypes()
Answer: (c) describe()
56. Which command displays only the column names of a DataFrame?
- (a) df.names
- (b) df.columns
- (c) df.index
- (d) df.header
Answer: (b) df.columns
57. Which command displays only the row labels (index values)?
- (a) df.rows
- (b) df.columns
- (c) df.index
- (d) df.labels
Answer: (c) df.index
58. What is the output of:
df = pd.DataFrame({
'A':[10,20],
'B':[30,40]
})
print(df.ndim)
- (a) 1
- (b) 2
- (c) 3
- (d) 4
Answer: (b) 2
59. Which method is used to rename a column in a DataFrame?
- (a) modify()
- (b) update()
- (c) rename()
- (d) change()
Answer: (c) rename()
60. Which method returns the data types of all columns in a DataFrame?
- (a) datatype()
- (b) types()
- (c) dtypes
- (d) info()
Answer: (c) dtypes


