Question
1.
2.
3.
4.
Answer (Detailed Solution Below)
Option 2 : [4.0] / [4.0]
Advertisement
Detailed Solution
सही उत्तर [4.0] / [4.0] है।
Key Points
Helpful?
Question:
What does the following Python code print? import pandas as pd; import numpy as np; s = pd.Series([1, 2, np.nan, 4]); print(s[s > 2].tolist()) / निम्नलिखित Python कोड क्या प्रिंट करेगा?
1.
[nan, 4.0] / [nan, 4.0]
2.
[4.0] / [4.0]
3.
[2.0, 4.0] / [2.0, 4.0]
4.
[1.0, 2.0, 4.0] / [1.0, 2.0, 4.0]
Correct Answer: [4.0] / [4.0]
Any comparison with NaN evaluates to False, so the mask s > 2 is False for the NaN entry and boolean indexing keeps only the value 4.0. / NaN से कोई भी तुलना False होती है, अतः NaN प्रविष्टि हेतु मास्क s > 2 False है और बूलियन इंडेक्सिंग केवल मान 4.0 रखती है।
Downloaded from PrepSnap (prepsnap.in)