Skip to main contentSkip to solution

Which of the following statements are TRUE?

(A) Addition of a new row to a DataFrame 'df' can be acheived with the help of df.loc[]

(B) Pandas.DataFrame.append() method is used to merge two DataFrames.

(C) Slicing is the only way to access elements of a series.

(D) DataFrame.D gives the transpose of a DataFrame.

Solution

✅ Correct Option: 2

(A) is true: assigning to a new index label, such as df.loc[new_label] = [values], adds a new row to the DataFrame.

(B) is true: DataFrame.append() joins the rows of one DataFrame to another, so it is used to combine two DataFrames.


(C) is false: a Series element can also be accessed by its index label (s['a']) or by position (s[0], s.iloc[0]), so slicing is not the only way.

(D) is false: the transpose is given by DataFrame.T, not DataFrame.D.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question