1. Home
  2. Subjects
  3. Data Science

Data Science MCQs · Page 23

1,613 multiple choice questions with answers across 28 topics.

Showing 551–575 of 1,613

df2 = df[df.a > 0]; df2['b'] = 1; raises SettingWithCopyWarning. Why?

  1. Because boolean indexing always returns a tuple of arrays, so assignment cannot tell which of the two arrays to modify in place here
  2. Because column b does not exist in df, so pandas must decide whether to create it on the copy or on the parent frame
  3. Boolean indexing returns a new object that may still reference the parent's data, so chained assignment has an ambiguous target Correct answer
  4. Because assigning a scalar to a new column is not allowed after filtering, and pandas raises a warning instead
MCQSEXAM Read explanation