Question
1.
2.
3.
4.
Answer (Detailed Solution Below)
Option 4 : [2, 3, 4] / [2, 3, 4]
Advertisement
Detailed Solution
सही उत्तर [2, 3, 4] / [2, 3, 4] है।
Key Points
Helpful?
Question:
What does the following Python code print? import pandas as pd; df = pd.DataFrame({'A': [1, 2, 3, 4]}, index=['w', 'x', 'y', 'z']); print(df.loc['x':'z', 'A'].tolist()) / निम्नलिखित Python कोड क्या प्रिंट करेगा?
1.
[2, 3] / [2, 3]
2.
[1, 2, 3] / [1, 2, 3]
3.
[3, 4] / [3, 4]
4.
[2, 3, 4] / [2, 3, 4]
Correct Answer: [2, 3, 4] / [2, 3, 4]
Unlike positional slicing, label-based .loc slicing includes the stop label, so rows 'x', 'y' and 'z' are all selected, giving [2, 3, 4]. / स्थितिगत स्लाइसिंग के विपरीत, लेबल-आधारित .loc स्लाइसिंग अंतिम लेबल को भी शामिल करती है, अतः 'x', 'y' और 'z' पंक्तियाँ सभी चुनी जाती हैं, जिससे [2, 3, 4] मिलता है।
Downloaded from PrepSnap (prepsnap.in)