Pandas MCQs with answers Page - 12

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 writes DataFrame to an Excel file?

  • (A) df.write_excel()
  • (B) df.to_excel()
  • (C) df.save_excel()
  • (D) df.export_excel()

A

Admin • 833.24K Points
Coach

Q. What does `df.at[3, 'B']` return?

  • (A) A slice of DataFrame
  • (B) Value at row 3, column 'B'
  • (C) A Series of row 3
  • (D) Entire column 'B'

A

Admin • 833.24K Points
Coach

Q. Which method checks if a DataFrame contains only numeric values?

  • (A) df.isnumeric()
  • (B) df.applymap(lambda x: isinstance(x, (int, float))).all().all()
  • (C) df.is_numeric()
  • (D) df.has_numeric()

A

Admin • 833.24K Points
Coach

Q. What does `df['col'].astype(str)` do?

  • (A) Casts column to object type
  • (B) Casts column to string type
  • (C) Removes NaN values
  • (D) Converts entire DataFrame

A

Admin • 833.24K Points
Coach

Q. How to get the number of rows and columns in a DataFrame?

  • (A) df.length
  • (B) df.shape
  • (C) df.size
  • (D) df.rows_columns()

A

Admin • 833.24K Points
Coach

Q. What is the output of `df.iloc[:, 0]`?

  • (A) First row
  • (B) First column
  • (C) Last column
  • (D) Last row

A

Admin • 833.24K Points
Coach

Q. What is returned by `df.mean(axis=1)`?

  • (A) Mean of each row
  • (B) Mean of each column
  • (C) Sum of each row
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. Which is the correct method to rename columns?

  • (A) df.rename(columns={'old': 'new'})
  • (B) df.columns.rename({'old': 'new'})
  • (C) df.rename_column({'old': 'new'})
  • (D) df.change_names({'old': 'new'})

A

Admin • 833.24K Points
Coach

Q. Which function appends one DataFrame below another?

  • (A) concat([df1, df2])
  • (B) append(df1, df2)
  • (C) merge(df1, df2)
  • (D) add(df1, df2)

A

Admin • 833.24K Points
Coach

Q. What is the default behavior of `pd.concat()`?

  • (A) Concatenate along columns
  • (B) Concatenate along rows
  • (C) Join by index
  • (D) Join by key