Q.Write the statement to get NewDelhi as output using positional index.
[Context: In the textbook, seriesCapCntry = pd.Series(['NewDelhi', 'WashingtonDC', 'London', 'Paris'], index=['India', 'USA', 'UK', 'France']).]
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Use the integer position 0 inside square brackets on the Series to access the first element by its positional index, yielding 'NewDelhi'.
This question tests a fundamental distinction in Pandas: label-based indexing vs positional indexing. The Series seriesCapCntry has string labels as its index ('India', 'USA', etc.), but the question explicitly asks for the positional index — that is, the integer position of the element in the underlying array, starting from 0.
When you write seriesCapCntry[0], Pandas first checks whether 0 is a valid label in the index. Since the index contains strings, 0 is not a label, so Pandas falls back to positional indexing and returns the element at position 0: 'NewDelhi'. …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.