πŸ“Š Pandas
Q. Which method is used to sort a DataFrame by column values?
  • (A) sort_values()
  • (B) sort_index()
  • (C) order()
  • (D) rank()
πŸ’¬ Discuss
βœ… Correct Answer: (A) sort_values()

Explanation: sort_values() sorts a DataFrame based on the values of one or more columns.

πŸ“Š Pandas
Q. Which pandas function is used to group data?
  • (A) groupby()
  • (B) aggregate()
  • (C) pivot_table()
  • (D) merge()
πŸ’¬ Discuss
βœ… Correct Answer: (A) groupby()

Explanation: The groupby() method groups data according to one or more columns for aggregation or transformation.

πŸ“Š Pandas
Q. Which function is used to merge two DataFrames on a key column?
  • (A) concat()
  • (B) merge()
  • (C) join()
  • (D) combine()
πŸ’¬ Discuss
βœ… Correct Answer: (B) merge()

Explanation: merge() combines two DataFrames based on common columns or indices, similar to SQL joins.

πŸ“Š Pandas
Q. Which method returns the unique values of a Series?
  • (A) unique()
  • (B) nunique()
  • (C) distinct()
  • (D) values()
πŸ’¬ Discuss
βœ… Correct Answer: (A) unique()

Explanation: The unique() method returns an array of unique values present in a Series.

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

Explanation: The nunique() method returns the count of distinct values in a Series.

πŸ“Š Pandas
Q. Which method is used to create a pivot table in pandas?
  • (A) pivot()
  • (B) pivot_table()
  • (C) groupby()
  • (D) melt()
πŸ’¬ Discuss
βœ… Correct Answer: (B) pivot_table()

Explanation: pivot_table() creates a spreadsheet-style pivot table for aggregation and analysis.

πŸ“Š Pandas
Q. Which method is used to reset the index of a DataFrame?
  • (A) reset_index()
  • (B) set_index()
  • (C) reindex()
  • (D) drop_index()
πŸ’¬ Discuss
βœ… Correct Answer: (A) reset_index()

Explanation: reset_index() resets the index of a DataFrame, converting the current index into a column.

πŸ“Š Pandas
Q. Which method is used to check for missing values in a DataFrame?
  • (A) isna()
  • (B) notna()
  • (C) fillna()
  • (D) dropna()
πŸ’¬ Discuss
βœ… Correct Answer: (A) isna()

Explanation: The isna() method returns a boolean DataFrame indicating the presence of NaN values.

πŸ“Š Pandas
Q. Which method converts a DataFrame to a NumPy array?
  • (A) to_numpy()
  • (B) asarray()
  • (C) array()
  • (D) values()
πŸ’¬ Discuss
βœ… Correct Answer: (A) to_numpy()

Explanation: The to_numpy() method returns the DataFrame as a NumPy array, preserving the data values.

πŸ“Š Pandas
Q. Which function is used to concatenate two DataFrames along rows or columns?
  • (A) concat()
  • (B) merge()
  • (C) append()
  • (D) combine()
πŸ’¬ Discuss
βœ… Correct Answer: (A) concat()

Explanation: pd.concat() can join multiple DataFrames either along rows (axis=0) or columns (axis=1).