Which Pandas method is used to select a subset of rows and columns from a…

2026

Which Pandas method is used to select a subset of rows and columns from a DataFrame based on their integer-based position (index location) rather than labels?

  1. A.

    .loc[]

  2. B.

    .at[]

  3. C.

    .iloc[]

  4. D.

    .ix[]

Attempted by 113 students.

Show answer & explanation

Correct answer: C

The correct method for selecting rows and columns based on integer-based positions in Pandas is .iloc[]. Unlike .loc, which uses labels, .iloc specifically targets integer-location-based indexing.

Explore the full course: Bpsc