Q. Which pandas method is used to count the frequency of values in a Series?

  • (A) count()
  • (B) value_counts()
  • (C) nunique()
  • (D) unique()
πŸ’¬ Discuss
βœ… Correct Answer: (B) value_counts()
Explanation: value_counts() counts the number of occurrences of each unique value in a Series.

Q. Which method removes all rows where any column is NaN in a DataFrame?

  • (A) dropna()
  • (B) fillna()
  • (C) replace()
  • (D) notna()
πŸ’¬ Discuss
βœ… Correct Answer: (A) dropna()
Explanation: dropna() removes rows (or columns) that contain missing values (NaN).

Q. Which method replaces NaN with a specified value in a DataFrame or Series?

  • (A) fillna()
  • (B) replace()
  • (C) dropna()
  • (D) isna()
πŸ’¬ Discuss
βœ… Correct Answer: (A) fillna()
Explanation: fillna() is used to fill missing values (NaN) with a specified value.

Q. Which pandas method returns the rank of each element in a Series?

  • (A) rank()
  • (B) order()
  • (C) sort()
  • (D) argsort()
πŸ’¬ Discuss
βœ… Correct Answer: (A) rank()
Explanation: rank() assigns ranks to elements in a Series, dealing with ties using methods like average, min, or max.

Q. Which method is used to convert a DataFrame to a CSV file?

  • (A) to_csv()
  • (B) write_csv()
  • (C) save_csv()
  • (D) export_csv()
πŸ’¬ Discuss
βœ… Correct Answer: (A) to_csv()
Explanation: to_csv() writes a DataFrame to a CSV file, optionally including the index or header.

Q. Which method transposes rows and columns in a DataFrame?

  • (A) transpose()
  • (B) T
  • (C) Both A and B
  • (D) swap()
πŸ’¬ Discuss
βœ… Correct Answer: (C) Both A and B
Explanation: Both transpose() and the T attribute transpose rows and columns of a DataFrame.

Q. Which method is used to calculate the cumulative maximum in a Series or DataFrame?

  • (A) cummax()
  • (B) max()
  • (C) cumsum()
  • (D) cumprod()
πŸ’¬ Discuss
βœ… Correct Answer: (A) cummax()
Explanation: cummax() returns the cumulative maximum of the values over rows or columns.

Q. Which pandas method is used to interpolate missing data in a DataFrame or Series?

  • (A) interpolate()
  • (B) fillna()
  • (C) replace()
  • (D) dropna()
πŸ’¬ Discuss
βœ… Correct Answer: (A) interpolate()
Explanation: interpolate() fills missing values using linear or other interpolation methods.

Q. Which method returns the index labels of a Series or DataFrame where values are True?

  • (A) where()
  • (B) mask()
  • (C) idxmax()
  • (D) nonzero()
πŸ’¬ Discuss
βœ… Correct Answer: (A) where()
Explanation: The where() method returns elements or indexes where a condition is True, often used with boolean masks.