Pandas MCQs with answers Page - 7

Here, you will find a collection of MCQ questions on Pandas. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 833.24K Points
Coach

Q. Which method allows you to fill NaN values with the previous non-null value?

  • (A) fillna(method='forward')
  • (B) fillna(method='ffill')
  • (C) fillna(method='bfill')
  • (D) fillna(method='pad')

A

Admin • 833.24K Points
Coach

Q. What does `df.duplicated().sum()` return?

  • (A) Total duplicate values in the DataFrame
  • (B) Total duplicate rows in the DataFrame
  • (C) Total NaN values
  • (D) Number of rows

A

Admin • 833.24K Points
Coach

Q. Which method sets a specific column as the index of a DataFrame?

  • (A) set_index()
  • (B) make_index()
  • (C) create_index()
  • (D) index_col()

A

Admin • 833.24K Points
Coach

Q. How can you reset a DataFrame index without keeping the old one?

  • (A) reset_index()
  • (B) reset_index(drop=True)
  • (C) reset_index(inplace=True)
  • (D) drop_index()

A

Admin • 833.24K Points
Coach

Q. Which method finds the cumulative sum of a column?

  • (A) sum()
  • (B) cumsum()
  • (C) cumulativesum()
  • (D) accumulate()

A

Admin • 833.24K Points
Coach

Q. What does `df['col'].str.contains('abc')` return?

  • (A) A filtered DataFrame with 'abc'
  • (B) Boolean Series where each element tells if 'abc' exists
  • (C) List of all values that contain 'abc'
  • (D) Index of matching rows

A

Admin • 833.24K Points
Coach

Q. Which method groups data and returns the size of each group?

  • (A) groupby().count()
  • (B) groupby().sum()
  • (C) groupby().size()
  • (D) groupby().value_counts()

A

Admin • 833.24K Points
Coach

Q. Which of the following creates a DataFrame from a list of dictionaries?

  • (A) pd.DataFrame.from_dict(list_of_dicts)
  • (B) pd.DataFrame(list_of_dicts)
  • (C) pd.Series(list_of_dicts)
  • (D) pd.DictFrame(list_of_dicts)

A

Admin • 833.24K Points
Coach

Q. Which method returns the number of dimensions in a DataFrame?

  • (A) df.ndim
  • (B) df.shape
  • (C) df.len()
  • (D) df.columns

A

Admin • 833.24K Points
Coach

Q. Which parameter of `groupby()` is used to avoid setting the grouped column as index?

  • (A) reset_index=True
  • (B) index=False
  • (C) as_index=False
  • (D) drop_index=True