Question

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

Option 1 : df.iloc[0:2] selects the first two rows by position, excluding the stop position / df.iloc[0:2] स्थिति के अनुसार पहली दो पंक्तियाँ चुनता है, अंतिम स्थिति को छोड़कर

Advertisement

Detailed Solution

सही उत्तर df.iloc[0:2] selects the first two rows by position, excluding the stop position / df.iloc[0:2] स्थिति के अनुसार पहली दो पंक्तियाँ चुनता है, अंतिम स्थिति को छोड़कर है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

Which statement about pandas indexing is TRUE? / pandas इंडेक्सिंग के बारे में कौन-सा कथन सत्य है?

1.
df.iloc[0:2] selects the first two rows by position, excluding the stop position / df.iloc[0:2] स्थिति के अनुसार पहली दो पंक्तियाँ चुनता है, अंतिम स्थिति को छोड़कर
2.
df.loc['a':'c'] excludes the row labelled 'c' / df.loc['a':'c'] 'c' लेबल वाली पंक्ति को छोड़ देता है
3.
df.iloc uses labels while df.loc uses integer positions / df.iloc लेबल और df.loc पूर्णांक स्थिति का उपयोग करता है
4.
Both iloc and loc always include the stop value in slices / दोनों स्लाइस में अंतिम मान शामिल करते हैं

Correct Answer: df.iloc[0:2] selects the first two rows by position, excluding the stop position / df.iloc[0:2] स्थिति के अनुसार पहली दो पंक्तियाँ चुनता है, अंतिम स्थिति को छोड़कर

iloc slices by integer position and excludes the stop, like Python slicing; loc slices by label and includes the stop label. The two are not interchangeable. / iloc पूर्णांक स्थिति से स्लाइस करता है और अंतिम स्थिति को छोड़ता है, जैसे पायथन स्लाइसिंग; loc लेबल से स्लाइस करता है और अंतिम लेबल को शामिल करता है। दोनों परस्पर बदले नहीं जा सकते।

Downloaded from PrepSnap (prepsnap.in)