πŸ“Š Pandas
Q. Which method is used to rename columns in a pandas DataFrame?
  • (A) rename_columns()
  • (B) rename()
  • (C) set_columns()
  • (D) update_columns()
πŸ’¬ Discuss
βœ… Correct Answer: (B) rename()

Explanation: The rename() method allows you to rename columns or index labels in a DataFrame using a dictionary mapping.

πŸ“Š Pandas
Q. Which function is used to drop a column or row from a DataFrame?
  • (A) drop()
  • (B) remove()
  • (C) delete()
  • (D) discard()
πŸ’¬ Discuss
βœ… Correct Answer: (A) drop()

Explanation: The drop() method removes specified rows or columns from a DataFrame.

πŸ“Š Pandas
Q. Which method returns the data type of each column in a DataFrame?
  • (A) dtypes
  • (B) info()
  • (C) type()
  • (D) datatype()
πŸ’¬ Discuss
βœ… Correct Answer: (A) dtypes

Explanation: The dtypes attribute shows the data type of each column in a DataFrame.

πŸ“Š Pandas
Q. Which method provides a concise summary of a DataFrame including column names, non-null counts, and data types?
  • (A) describe()
  • (B) info()
  • (C) summary()
  • (D) head()
πŸ’¬ Discuss
βœ… Correct Answer: (B) info()

Explanation: The info() method gives an overview of the DataFrame including column names, non-null counts, and data types.

πŸ“Š Pandas
Q. Which pandas method is used to combine two DataFrames along columns?
  • (A) concat(axis=1)
  • (B) merge()
  • (C) append()
  • (D) join()
πŸ’¬ Discuss
βœ… Correct Answer: (A) concat(axis=1)

Explanation: Using pd.concat() with axis=1 combines DataFrames along columns.

πŸ“Š Pandas
Q. Which function is used to count the occurrences of unique values in a Series?
  • (A) unique()
  • (B) nunique()
  • (C) value_counts()
  • (D) count_unique()
πŸ’¬ Discuss
βœ… Correct Answer: (C) value_counts()

Explanation: The value_counts() method counts how many times each unique value appears in a Series.

πŸ“Š Pandas
Q. Which method reshapes a DataFrame from wide to long format?
  • (A) melt()
  • (B) pivot()
  • (C) stack()
  • (D) unstack()
πŸ’¬ Discuss
βœ… Correct Answer: (A) melt()

Explanation: The melt() method converts wide format DataFrames into long format for easier analysis.

πŸ“Š Pandas
Q. Which pandas method is used to remove duplicate rows from a DataFrame?
  • (A) drop_duplicates()
  • (B) remove_duplicates()
  • (C) unique()
  • (D) distinct()
πŸ’¬ Discuss
βœ… Correct Answer: (A) drop_duplicates()

Explanation: The drop_duplicates() method removes duplicate rows based on all or selected columns.

πŸ“Š Pandas
Q. Which function is used to get the index of a DataFrame?
  • (A) columns
  • (B) index
  • (C) keys()
  • (D) labels()
πŸ’¬ Discuss
βœ… Correct Answer: (B) index

Explanation: The index attribute returns the row labels of a DataFrame.

πŸ“Š Pandas
Q. Which method is used to apply a function to each element of a Series or DataFrame?
  • (A) apply()
  • (B) map()
  • (C) transform()
  • (D) forEach()
πŸ’¬ Discuss
βœ… Correct Answer: (A) apply()

Explanation: The apply() method allows you to apply a function along rows or columns in a DataFrame, or to each element in a Series.