Q.Assertion (A) : The output of addition of two series will be NaN, if one of the elements or both the elements have no value(s). Reason (R) : While performing mathematical operations on a series, by default all missing values are filled in with 0. (A) Both (A) and (R) are true and (R) is the correct explanation for (A). (B) Both (A) and (R) are true and (R) is not the correct explanation for (A). (C) (A) is true and (R) is false. (D) (A) is false but (R) is true.
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →In pandas, adding two Series propagates NaN values (missing data remains missing), so Assertion (A) is true. Reason (R) claims missing values are filled with 0 by default, which is false — pandas preserves NaN in arithmetic. The answer is (C).
Understanding Missing Data in Pandas Series Operations
When you work with pandas Series, missing values are represented as NaN (Not a Number). The question asks what happens when you add two Series that contain missing values, and whether pandas automatically fills those gaps with zeros.
The core concept here is how pandas handles missing data during arithmetic operations. This behavior is fundamental to data analysis because real-world datasets almost always have gaps, and you need predictable rules for what happens when you compute with incomplete data.
Let's examine each statement:
Evaluating Assertion (A)
Assertion (A) claims that adding two Series produces NaN if one or both elements are missing.
This is true. Pandas follows the IEEE floating-point standard for NaN propagation: any arithmetic operation involving NaN returns NaN. If you add a number to NaN, you get NaN. If you add NaN to NaN, you still get NaN.
import pandas as pd
import numpy as np
s1 = pd.Series([1, 2, np.nan, 4])
s2 = pd.Series([10, np.nan, 30, 40])
result = s1 + s2
# Output: [11, NaN, NaN, 44]
Position 1: 2 + NaN = NaN
Position 2: NaN + 30 = NaN
The missing values propagate through the calculation, preserving the information that data was absent.
Evaluating Reason (R)
Reason (R) claims that pandas fills missing values with 0 by default during mathematical operations.
This is false. Pandas does not automatically fill missing values with any default value during arithmetic. The default behavior is to propagate NaN, as we just saw. If you wanted to treat missing values as zero, you would need to explicitly use methods like fillna(0) or pass fill_value=0 to the operation:
result_filled = s1.add(s2, fill_value=0) …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.