Question

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

Option 4 : 1 / 1

Advertisement

Detailed Solution

सही उत्तर 1 / 1 है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

What does the following Python code print? import pandas as pd; df = pd.DataFrame([{'a': 1, 'b': 2}, {'a': 3}]); print(df['b'].isna().sum()) / निम्नलिखित Python कोड क्या प्रिंट करेगा?

1.
0 / 0
2.
2 / 2
3.
KeyError / KeyError
4.
1 / 1

Correct Answer: 1 / 1

When a DataFrame is built from a list of dicts, a missing key becomes NaN; the second dict has no key 'b', so column 'b' contains exactly one NaN and the count is 1. / जब डिक्शनरियों की सूची से DataFrame बनता है, तो अनुपस्थित कुंजी NaN बन जाती है; दूसरे डिक्शनरी में 'b' कुंजी नहीं है, अतः 'b' स्तंभ में ठीक एक NaN है और गिनती 1 है।

Downloaded from PrepSnap (prepsnap.in)