Consider the two series given below:
Series A
index ValuesA a 10 b NaN c 20 d NaN e 10
Series B
index ValuesA a 10 b 15 c 20 d NaN e 14
What will be the output of SeriesA.mul(SeriesB) in Python?
Consider the two series given below:
Series A
| index | ValuesA |
|---|---|
| a | 10 |
| b | NaN |
| c | 20 |
| d | NaN |
| e | 10 |
Series B
| index | ValuesA |
|---|---|
| a | 10 |
| b | 15 |
| c | 20 |
| d | NaN |
| e | 14 |
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.
| index | Series A | Series B | A.mul(B) |
|---|---|---|---|
| a | 10 | 10 | 100 |
| b | NaN | 15 | NaN |
| c | 20 | 20 | 400 |
| d | NaN | NaN | NaN |
| e | 10 | 14 | 140 |
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.
Related questions:
2025: 13 May Shift 2
2026: 29 May Shift 2
2026: 26 May Shift 1