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.
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
(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.
Related questions:
2025: 30 May Shift 2
2025: 27 May Shift 2
2026: 29 May Shift 1