1. Home
  2. Data Science
  3. Pandas
  4. s1 has index [1, 2, 3] and s2 has index [2, 3, 4]. What is…

Added 30 Nov -0001

s1 has index [1, 2, 3] and s2 has index [2, 3, 4]. What is the result of s1 + s2?

  1. A ValueError, because the indexes are not identical
  2. A Series indexed 1 to 4, with zeros at 1 and 4
  3. A Series indexed 1 to 4, with NaN at 1 and 4 Correct answer
  4. A Series of length 3, added element-wise by position

Correct answer

C. A Series indexed 1 to 4, with NaN at 1 and 4

13 views

MCQSEXAM

Explanation

Arithmetic between Series aligns on the index labels and takes the union of the two indexes; labels 1 and 4 appear on one side only, so they hold NaN instead of raising an error or being summed by position.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Pandas MCQs

Practise all Pandas MCQs

Similar MCQs