Skip to main contentSkip to solution

Consider the two series given below:

Series A

indexValuesA
a10
bNaN
c20
dNaN
e10

Series B

indexValuesA
a10
b15
c20
dNaN
e14

What will be the output of SeriesA.mul(SeriesB) in Python?

Solution

✅ Correct Option: 4

Series.mul() multiplies the two series element by element, matching them on index labels. Without a fill_value, any position where either value is NaN gives NaN.

indexSeries ASeries BA.mul(B)
a1010100
bNaN15NaN
c2020400
dNaNNaNNaN
e1014140

Options 1 and 2: NaN is not treated as 0 here. It would be replaced only if fill_value=0 were passed, and even then position d would give 0 only if the fill applied to both series. By default (no fill_value), positions b and d stay NaN.

Option 3: this would be the result of adding or filling with the identity, not of multiplying.

Keyboard Shortcuts

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