Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 1 : [1.0, 3.0, 3.0, 3.0, 5.0] / [1.0, 3.0, 3.0, 3.0, 5.0]

Advertisement

Detailed Solution

सही उत्तर [1.0, 3.0, 3.0, 3.0, 5.0] / [1.0, 3.0, 3.0, 3.0, 5.0] है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

Predict the output of the following Python code: import pandas as pd; import numpy as np; s = pd.Series([1, np.nan, 3, np.nan, 5]); print(s.fillna(s.mean()).tolist()) / निम्नलिखित Python कोड के आउटपुट का अनुमान लगाइए:

1.
[1.0, 3.0, 3.0, 3.0, 5.0] / [1.0, 3.0, 3.0, 3.0, 5.0]
2.
[1.0, 0.0, 3.0, 0.0, 5.0] / [1.0, 0.0, 3.0, 0.0, 5.0]
3.
[1.0, 3.0, 5.0] / [1.0, 3.0, 5.0]
4.
[1, nan, 3, nan, 5] / [1, nan, 3, nan, 5]

Correct Answer: [1.0, 3.0, 3.0, 3.0, 5.0] / [1.0, 3.0, 3.0, 3.0, 5.0]

s.mean() ignores NaN and averages the present values, (1 + 3 + 5) / 3 = 3.0; fillna replaces both NaN entries with 3.0, giving [1.0, 3.0, 3.0, 3.0, 5.0]. / s.mean() NaN को अनदेखा कर उपस्थित मानों का औसत, (1 + 3 + 5) / 3 = 3.0 निकालता है; fillna दोनों NaN प्रविष्टियों को 3.0 से बदल देता है, जिससे [1.0, 3.0, 3.0, 3.0, 5.0] मिलता है।

Downloaded from PrepSnap (prepsnap.in)