Skip to main contentSkip to solution

What is the result of the following code for Series?

s = pd.Series([25,30,35,40])

s = s + pd.Series([45,50,55,60])

Solution

✅ Correct Option: 3

Adding two pandas Series works element-wise, matching values by index label. Both Series have the default index 0,1,2,30, 1, 2, 3, so each pair is added directly.

[25+45, 30+50, 35+55, 40+60]=[70,80,90,100][25+45,\ 30+50,\ 35+55,\ 40+60] = \boxed{[70, 80, 90, 100]}


Option 4: this is what + does for Python lists (concatenation), not for pandas Series.

If the index labels did not match, the unmatched positions would give NaN instead of a sum.

Keyboard Shortcuts

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