Skip to content
Question 32 of 38

Q.In Pandas, when extracting a portion of a Series ser1 using ser1[start:end] with positional indices start and end, which of the following statements is true ? (A) The element at the end index is included in the output. (B) The element at the end index is excluded from the output. (C) The elements at both the start and end indices are excluded from the output. (D) The element at the start index is excluded from the output.

Tripura TbseCBSE Class XII Board 2026MCQ· 1mImportance★★★★★
84% · 32/38 Questions
🔒 Locked · start free trial →

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 →

Pandas Series slicing with positional indices follows Python's standard slicing convention: ser1[start:end] includes the element at start but excludes the element at end. The answer is (B).

Why Pandas slicing works this way

Pandas inherits Python's fundamental slicing behavior for positional (integer-location) indexing. When you write ser1[start:end], you're using implicit positional indexing (iloc-style), which follows the half-open interval convention: from start up to but not including end, written as [start, end).

This design choice is deliberate and consistent across Python sequences (lists, tuples, strings). The half-open interval makes slice arithmetic clean: the length of ser1[start:end] is always end - start, and consecutive slices like ser1[0:3] and ser1[3:6] partition the data without overlap or gaps.

Step-by-step verification

  1. Create a simple Series to test

    Consider a Series with five elements at positions 0, 1, 2, 3, 4:

    import pandas as pd
    ser1 = pd.Series(['A', 'B', 'C', 'D', 'E'])
    

    The positional indices are 0 through 4.

  2. Extract a slice using positional indices

    If we write ser1[1:4], we're asking for elements starting at position 1 up to (but not including) position 4:

    result = ser1[1:4]
    # Output: 1    B
    #         2    C
    #         3    D
    

    Position 1 ('B') is included, position 4 ('E') is excluded.

  3. Check the boundary behavior

    • The element at start = 1 appears in the output.
    • The element at end = 4 does not appear in the output.
    • This confirms the half-open interval [1, 4) — positions 1, 2 and 3 only.
  4. Evaluate each option …

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.